codeforces 687A link asked 06 Nov '17, 16:26

A greedy solution will work. Store all the edges and take a mark[] array. The graph may or may not be connected. So, for each of it's component run a DFS from any starting vertex say, X. Mark X=1. Now, in the DFS function, if the parent vertex is marked as 1, mark the children vertex with 2 else mark it with 1. answered 06 Nov '17, 17:03
