#P15728. [JAG 2023 Summer Camp #3] Odd trip plans

[JAG 2023 Summer Camp #3] Odd trip plans

题目描述

JAG is a country with nn airports numbered through 11 to nn. There are some airways, each of which connects two different airports bidirectionally. In other words, if an airway connects airports uu and vv, a passenger can move either from uu to vv or from vv to uu in a single flight. Airways may be newly established or abolished.

Mr. Oddytrip, who is a traveler loving odd numbers, plans a trip from an airport to another one by flights. Let's say that he boards kk flights: A flight from airport p1p_1 to p2p_2, then from p2p_2 to p3p_3, then from p3p_3 to p4p_4, and so on, and finally from pkp_k to pk+1p_{k+1}. This trip plan, which begins with p1p_1 and ends with pk+1p_{k+1}, is written as $p_1 \rightarrow p_2 \rightarrow p_3 \rightarrow p_4 \rightarrow \cdots \rightarrow p_k \rightarrow p_{k+1}$. According to his aesthetics, a trip plan is beautiful if each of nn airports appears an odd number of times in the trip plan. For example, if n=6n = 6, trip plans $3 \rightarrow 4 \rightarrow 5 \rightarrow 6 \rightarrow 1 \rightarrow 2$ and $1 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 5 \rightarrow 3 \rightarrow 2 \rightarrow 3 \rightarrow 2 \rightarrow 6$ are beautiful while 1361 \rightarrow 3 \rightarrow 6 and $1 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 1 \rightarrow 5 \rightarrow 6$ aren't. In particular, each of the nn airports appears at least one in a beautiful trip plan.

Initially, there are mm airways. Then, you are given qq queries, which should be processed in the order they are given. Each query is of one of the two kinds below:

  • 1 x y1 \ x \ y: The existence of the airway between airports xx and yy changes. If there is already an airway between airports xx and yy, then such an airway is abolished. In other words, Mr. Oddytrip is no longer able to board the direct flight between airports xx and yy (until it is newly established again). On the other hand, if there wasn't such an airway before, an airway between airports xx and yy is newly established. In other words, Mr. Oddytrip can board a direct flight between airports xx and yy (until it is abolished again).
  • 2 x y2 \ x \ y: You have to determine whether there can be a beautiful trip plan which begins with airport xx and ends with airport yy using the airways which are available at that time.

输入格式

The input consists of a single test case of the following format.

$$\begin{aligned} &n \ m \ q \\ &u_1 \ v_1 \\ &\vdots \\ &u_m \ v_m \\ &t_1 \ x_1 \ y_1 \\ &\vdots \\ &t_q \ x_q \ y_q \end{aligned} $$

The first line consists of three integers nn, mm and qq (2n100,0002 \leq n \leq 100,000, 0m100,0000 \leq m \leq 100,000, 1q100,0001 \leq q \leq 100,000), where nn is the number of airports in JAG country, mm is the number of airways which are initially available, and qq is the number of queries.

The ii-th of the following mm lines consists of two integers uiu_i and viv_i (1ui<vin1 \leq u_i < v_i \leq n) representing that an airway between airports uiu_i and viv_i is initially available. It is guaranteed that these mm airways are distinct.

The jj-th of the following qq lines consists of three integers tjt_j, xjx_j and yjy_j (1tj21 \leq t_j \leq 2, 1xj<yjn1 \leq x_j < y_j \leq n) representing the type of the query and the numbers of two airports as described above. It is guaranteed that there is at least one query where tj=2t_j = 2.

输出格式

For each query where tj=2t_j = 2, print "Yes" in a single line if there can be a beautiful trip plan which begins with airport xx and ends with airport yy. Otherwise, print "No" in a single line.

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
No
Yes
Yes
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

Yes
No
Yes