영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
Consider an undirected graph that consists of n nodes and m edges. There are two types of events that can happen:
- A new edge is created between nodes a and b.
- An existing edge between nodes a and b is removed.
Your task is to report the number of components after every event.
Input
The first input line has three integers n, m and k: the number of nodes, edges and events.
After this there are m lines describing the edges. Each line has two integers a and b: there is an edge between nodes a and b. There is at most one edge between any pair of nodes.
Then there are k lines describing the events. Each line has the form "t a b" where t is 1 (create a new edge) or 2 (remove an edge). A new edge is always created between two nodes that do not already have an edge between them, and only existing edges can get removed.
Output
Print k+1 integers: first the number of components before the first event, and after this the new number of components after each event.
Constraints
- 2 ≤ n ≤ 10^5
- 1 ≤ m,k ≤ 10^5
- 1 ≤ a,b ≤ n
예제
예제 1
5 3 3 1 4 2 3 3 5 1 2 5 2 3 5 1 1 2
2 2 2 1