跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F0740. Bipartite Checking

    ID: 746 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数据结构并查集图论挑战难度共享题库Codeforces英文题面题目来源题面语言

Bipartite Checking

题目描述

F. Bipartite Checking
time limit per test
6 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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

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

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

Output

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

Example
Input
3 5
2 3
1 3
1 2
1 2
1 2
Output
YES
YES
NO
YES
NO


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 159 题。保留原作者与原赛事署名。