How to solve this ques?(codeforces)

Tutorial is quite straight forward .
You shouldn’t be having any trouble understanding it.

Sort edges according to frequency it occurs in any of the path in ascending order and then label each edge from 0 to n-2 in this order.

This question is already discussed here.

You don’t need to do that. Just find a node 3 or more edges, and the largest MEX will be 2 if you put 0 1 2 on them.If there isn’t such a node it’s a line and you can’t do anything.

Yup, we can also do this. I just shared my approach :grinning:

1 Like