Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

fernandezpalomojosue's blog

By fernandezpalomojosue, history, 13 months ago, In English

On example,2nd test case, in the third query already exist a path with distances 3 between 2 leaves , 5-4-2-3, but the answer wasn't "-1 -1 -1".Am I receiving WA veredict for that? Submision:233191318.

»
13 months ago, # |
  Vote: I like it +16 Vote: I do not like it

your code is doing wrong when 4 is reppearing, in that case ur tree is

1-2-3-5

1-2-4

there is no 2 leaf nodes with distance 4.