Still Two Teams?
Edges arrive one by one. After each edge, print whether the graph built SO FAR is still bipartite (once it stops being bipartite it stays that way).
Input: the first line has N and M; each of the next M lines has an edge u v.
Output: M lines of YES/NO.
Constraints:
- 1 ≤ N, M ≤ 105
Sample Tests
Input 1
3 3 1 2 2 3 1 3
Output 1
YES YES NO
Input 2
2 2 1 2 1 2
Output 2
YES YES
Discussion (opens after you solve — no spoilers before)
No comments yet.