Loading...
Loading...
Loading...
A coach has n players and m pairs of players who must not be on the same team. Decide whether everyone can be placed in one of two teams so that no pair is on the same team.
Example 1
Input
4 4 0 1 1 2 2 3 3 0
Output
YES
Example 2
Input
3 3 0 1 1 2 2 0
Output
NO
Try the problem first. Open one hint at a time.
Colour the first player of each group red and its conflicts blue, and keep alternating.
Meeting a neighbour that already has your own colour means NO.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor