시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
0.5 초 (추가 시간 없음) | 1024 MB (추가 메모리 없음) | 1043 | 144 | 116 | 18.650% |
This is an interactive problem.
You are given n vertices and q queries, initially with no edges. The vertices are numbered from 1 to n. Each of the queries is one of the two types below:
1 a b
: makes an undirected edge connecting vertex a and vertex b. It is guaranteed that the edge a - b does not already exist when this query is processed.2 a b
: disconnects the edge connecting vertex a and vertex b. It is guaranteed that the edge a - b already exists when this query is processed.Your job is to print the number of connected components after each query is processed.
The first line contains n and q, which satisfy 2 ≤ n ≤ 106 and 1 ≤ q ≤ 106. Then the interaction starts.
Queries are given as stated above, one line per query. Thus you will be reading q lines total for the interaction. They are given in order, i.e. i-th query is never given before j-th query if i > j.
Moreover, to further force you to process each query in order, for 1 ≤ i ≤ q, i-th query is given only after you print the answer for at least (i-1) queries. If you want to be qualified as having printed what you had ordered to print, flush the stream as stated below:
fflush(stdout);
std::cout << std::flush;
System.out.flush();
sys.stdout.flush()
For other languages refer to their respective references.
It is guaranteed that after each query the graph does not contain self-loops or multiple edges.
2 2 1 1 2 2 2 1
1 2
It is guaranteed that after each query the graph does not contain self-loops or multiple edges.
Contest > BOJ User Contest > 구데기컵 > 진짜 최종 구데기컵 2 2 $\displaystyle\sum_{k=0}^{\infty}📏$번