STEPUP: Need Output

For the practice problem Stepping Up, what should be the output for the following input?

1
3 3
1 2
1 3
2 3

After spending quite some time trying to solve the problem, I checked an accepted solution and it is giving “IMPOSSIBLE” for the above test case. Shouldn’t the answer be 3?

Yes, you are right, the answer should be 3.
The solution you are talking about is definitely wrong.(weak test cases)

Assigned values.

node #1 - 1
node #2 - 2
node #3 - 3

Your answer is correct.

May be its a bug in the answer you have seen.

I have checked with this Answer and it is giving answer as 3.

Node 1 - 1

Node 2 - 2 ( >f(1))

Node 3 - 3 ( >f(1) & >f(2))

Edit:

**P.S:**Also to mention, I am not 100% sure though, “IMPOSSIBLE” case occurs only when there is a cycle in the Graph. ( And clearly your test case is Acyclic )

1 Like

Hello Everyone,
I am getting the Runtime Error(NZEC) . I am new to codechef. Can anyone please provide the pointers.

yes, even I think that the presence of a cycle in the graph is a necessary and sufficient condition for “IMPOSSIBLE”. And I have checked for the same in my solution. But I am getting WA. Any hints as to what might be the problem with my code?

@ankit0311 i know that this is very late but check your answer for the following test case:

1

5 5

3 1

3 2

4 2

5 3

5 4

the answer is 3 but your program gives 4. See the graph formed, you will understand. This is my solution. This gives 3 and it is giving correct output for many cases. If you finding trouble in understanding let me know.