1773.Bipartite Checking

Time Limit: 1s Memory Limit: 256MB

You are given an undirected graph consisting of n vertices. Initially there are no edges in the graph. Also you are given q queries, each query either adds one undirected edge to the graph or removes it. After each query you have to check if the resulting graph is bipartite (that is, you can paint all vertices of the graph into two colors so that there is no edge connecting two vertices of the same color).

Input Format(From the terminal/stdin)

The first line contains two integers n and q (2 \le n,q \le 100000).

Then q lines follow. ith line contains two numbers xi and yi (1 \le xi \lt yi \le n). These numbers describe ith query: if there is an edge between vertices xi and yi, then remove it, otherwise add it.

Output Format(To the terminal/stdout)

Print q lines. ith line must contain YES if the graph is bipartite after ith query, and NO otherwise.

Sample Input

Copy
3 5
2 3
1 3
1 2
1 2
1 2
 · \n
 · \n
 · \n
 · \n
 · \n
 · \n

Sample Output

Copy
YES
YES
NO
YES
NO
   \n
   \n
  \n
   \n
  \n

Submit

请先 登录

© 2025 FAQs