I was trying to solve the question http://codeforces.net/contest/117/problem/E
I coded it but in one of the test cases my answer is differing from jury but i think that the jury's answer is not in accordance with the question ( I know that i am wrong because many people have got ac on that problem ) so i request the commumnity to solve my doubt.In the last case where the path from 5 to 6 is asked there are two paths
5 -> 6
5 -> 4 -> 3 -> 6
the smallest one is the first one while the lexicographically smallest one is the second one.The question asks to find the smallest path first so 5->6 shold be taken and the number of components is 5 which are {3},{4},{5,6},{1},{2} but the answer is 3 which is got when we take the second path ? Why . The first sample case is itself against this.
The test i am refering to is this.
6 4
6 3
4 3
1 5
1 2
5 4
5 6
1 1
3 3
5 2
5 6
PLEASE HELP!!