QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100

#10802. 贾盖卡王国

Statistics

Jagaica 王国是一个拥有 $n$ 个机场的国家,机场编号从 $1$ 到 $n$。王国中存在一些航线,每条航线双向连接两个不同的机场。换句话说,如果一条航线连接机场 $u$ 和 $v$,乘客可以在一次飞行中从 $u$ 移动到 $v$,或者从 $v$ 移动到 $u$。航线可以新建或撤销。

Threep 先生是一位热爱奇数的旅行者,他计划通过多次飞行从一个机场前往另一个机场。假设他乘坐了 $k$ 次航班:从机场 $p_1$ 到 $p_2$,然后从 $p_2$ 到 $p_3$,以此类推,最后从 $p_k$ 到 $p_{k+1}$。这个以 $p_1$ 开始并以 $p_{k+1}$ 结束的旅行计划记作 $p_1 \to p_2 \to p_3 \to p_4 \to \dots \to p_k \to p_{k+1}$。根据他的审美,如果一个旅行计划中 $n$ 个机场中的每一个都出现了奇数次,那么这个旅行计划就是“美丽的”。例如,当 $n=6$ 时,旅行计划 $3 \to 4 \to 5 \to 6 \to 1 \to 2$ 和 $1 \to 2 \to 3 \to 4 \to 5 \to 3 \to 2 \to 3 \to 2 \to 6$ 是美丽的,而 $1 \to 3 \to 6$ 和 $1 \to 2 \to 3 \to 4 \to 1 \to 5 \to 6$ 则不是。特别地,在美丽的旅行计划中,每个机场至少出现一次。

最初有 $m$ 条航线。随后,你将收到 $q$ 个查询,这些查询应按给定的顺序处理。每个查询属于以下两种类型之一:

  • “$1 \ x \ y$”:机场 $x$ 和 $y$ 之间的航线状态发生改变。如果机场 $x$ 和 $y$ 之间已经存在航线,则该航线被撤销。换句话说,Threep 先生无法再乘坐 $x$ 和 $y$ 之间的直飞航班(直到它再次被建立)。反之,如果之前不存在这样的航线,则在机场 $x$ 和 $y$ 之间建立一条新航线。换句话说,Threep 先生可以乘坐 $x$ 和 $y$ 之间的直飞航班(直到它再次被撤销)。
  • “$2 \ x \ y$”:你需要确定在当前可用的航线下,是否存在一个以机场 $x$ 开始并以机场 $y$ 结束的美丽旅行计划。

输入格式

输入的第一行包含三个整数 $n, m$ 和 $q$:王国中机场的数量、最初可用的航线数量以及查询的数量($2 \le n \le 10^5$;$1 \le m \le 10^5$;$1 \le q \le 10^5$)。

接下来的 $m$ 行中,第 $i$ 行包含两个整数 $u_i$ 和 $v_i$,表示机场 $u_i$ 和 $v_i$ 之间最初存在一条航线($1 \le u_i < v_i \le n$)。保证这 $m$ 条航线各不相同。

接下来的 $q$ 行中,第 $j$ 行包含三个整数 $t_j, x_j$ 和 $y_j$,分别表示查询类型以及上述两个机场的编号($1 \le t_j \le 2$;$1 \le x_j < y_j \le n$)。保证至少存在一个 $t_j = 2$ 的查询。

输出格式

对于每个 $t_j = 2$ 的查询,如果存在以机场 $x$ 开始并以机场 $y$ 结束的美丽旅行计划,则输出一行,包含单词 “Yes”,否则输出 “No”。

样例

样例输入 1

4 2 6
1 2
3 4
2 1 2
1 2 3
2 1 2
1 2 4
1 2 3
2 1 3

样例输出 1

No
Yes
Yes

样例输入 2

5 5 4
1 2
2 3
3 4
1 4
4 5
2 1 3
2 1 4
1 2 4
2 1 4

样例输出 2

Yes
No
Yes

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.