Universal Cup Judging System

Universal Cup

Time Limit: 4.0 s Memory Limit: 1024 MB Total points: 100
Statistics

给定一个无向图,图中没有重边或自环。你还有一个顶点集合 $U$,初始为空。你需要回答以下形式的查询:

  1. “+ v”。将顶点 $v$ 加入集合 $U$。保证 $v \notin U$。
  2. “- v”。从集合 $U$ 中移除顶点 $v$。保证 $v \in U$。
  3. “?”。寻找一条边,使得该边的两个端点中恰好有一个在 $U$ 中,并将其从图中删除。如果不存在这样的边,则输出 0。如果有多条边满足此条件,你可以选择其中任意一条。

输入格式

第一行包含两个整数 $n$ 和 $m$,分别表示图中的顶点数和边数 ($0 \le n, m \le 10^5$)。接下来的 $m$ 行,每行包含两个整数 $u$ 和 $v$,表示一条无向边的两个端点 ($1 \le u, v \le n$)。保证图中没有重边和自环。

下一行包含一个整数 $q$,表示查询次数 ($0 \le q \le 10^5$)。接下来的 $q$ 行包含上述格式的查询 ($1 \le v \le n$)。

输出格式

对于每个第三类查询,你的程序应输出所找到边的编号(按输入顺序,从 1 开始计数),如果不存在这样的边,则输出 0。

样例

输入格式 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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.