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

33363번 - Graph Cuts 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 2048 MB111100.000%

문제

You are given an undirected graph without multiple edges or self-loops. You also have a set of its vertices $U$ that is initially empty. Your task is to answer queries of the following form.

  1. "+ $v$". Add vertex $v$ to $U$. It is guaranteed that $v \not\in U$.
  2. "- $v$". Remove vertex $v$ from $U$. It is guaranteed that $v \in U$.
  3. "?". Find an edge such that exactly one of its endpoints is in $U$ and remove it from the graph, or determine that there are no such edges. If there are multiple edges that fulfill this property, you can choose any one of them.

입력

The first line contains two integers $n$ and $m$: the numbers of vertices and edges in the graph correspondingly (0ドル \le n, m \leq 10^5$). Each of the next $m$ lines contains two integers $u$ and $v$: the endpoints of a bidirectional edge (1ドル \leq u, v \leq n$). It is guaranteed that there are no multiple edges and no self-loops in the graph.

The next line contains a single integer $q,ドル the number of queries (0ドル \le q \leq 10^5$). The next $q$ lines contain queries in the format described above (1ドル \le v \le n$ in the queries).

출력

For each query of the third type, your program should either print a number of the found edge in the order it was presented in the input, or print 0ドル$ if such an edge does not exist.

제한

예제 입력 1

4 5
1 2
1 3
1 4
2 3
2 4
10
+ 1
+ 2
?
?
?
?
?
- 2
?
?

예제 출력 1

5
4
3
2
0
1
0

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 4: SPb SU Contest, LVII SPb SU Championship G번

채점 및 기타 정보

  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

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

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