Logo
(追記) (追記ここまで)

23686번 - Number Of Vertices 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB19141482.353%

문제

New meta.

A zigzag cycle in an undirected graph is a sequence of vertices $a_0, a_1, \ldots, a_{k-1},ドル \uline{not necessarily distinct}, such that for all $i: 0 \leq i < k$ $a_i$ and $a_{(i+1) \mod k}$ are adjacent in the graph and one of the following holds:

  1. $a_{(i+k-1)\mod k} < a_i, a_i > a_{(i+1) \mod k}$
  2. $a_{(i+k-1)\mod k} > a_i, a_i < a_{(i+1) \mod k}$

A cycle contains the edge $(u, v)$ $p$ times if there exist exactly $p$ distinct $i: 0 \leq i < k,ドル such that $a_i = u, a_{(i+1) \mod k} = v$ or $a_i = v, a_{(i+1) \mod k} = u$.

A graph is splittable if there exists a set of zigzag cycles, such that for each edge exactly one cycle contains it 1ドル$ time and all the remaining cycles contain it 0ドル$ times, i.e. you can split edges of the graph into zigzag cycles.

There is a graph which is initially empty. Process the following types of queries:

  1. Add an edge between vertices $u$ and $v$.
  2. Remove an edge between vertices $u$ and $v$.

After each query print whether the graph is splittable.

입력

The first line contains two integers $n$ and $q$ (2ドル \leq n \leq 3 \cdot 10^5, 1 \leq q \leq 3 \cdot 10^5$) --- the number of vertices in the graph and the number of queries, respectively.

$q$ lines follow. $i$-th of them contains three integers $t, u, v$ ($t \in \{1, 2\}, 1 \leq u < v \leq n$) --- the type of query and the endpoints of the edge you have to add if $t = 1$ or remove if $t = 2$. No query will ask to you to add an already present edge or to delete an absent one.

출력

Print $q$ lines. $i$-th of them should contain 1 if the graph is splittable after the first $i$ queries and 0 otherwise.

제한

예제 입력 1

6 10
1 1 4
1 1 5
1 4 5
1 3 5
1 3 4
2 4 5
1 4 5
1 2 5
1 2 6
1 4 6

예제 출력 1

0
0
0
0
0
1
0
0
0
1

노트

After processing all the queries one possible set of zigzag cycles is $\{[1,4,3,5], [2,6,4,5]\}$.

출처

Contest > Open Cup > 2018/2019 Season > Stage 13: Grand Prix of Bytedance N번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /