#abc278c. C - FF

C - FF

Score : 300300 points

问题描述

高桥运营了一个名为“Twidai”的SNS社交网络,该网络拥有从用户1到用户NNNN名用户。在Twidai中,用户可以关注或取消关注其他用户。

自Twidai上线以来,已经执行了QQ次操作。第ii次(1iQ1\leq i\leq Q)操作由三个整数TiT_iAiA_iBiB_i表示,它们的含义如下:

  • 如果Ti=1T_i = 1:表示用户AiA_i开始关注用户BiB_i。如果在此操作时用户AiA_i已经关注了用户BiB_i,则不会有任何改变。
  • 如果Ti=2T_i = 2:表示用户AiA_i取消关注用户BiB_i。如果在此操作时用户AiA_i并未关注用户BiB_i,则不会有任何改变。
  • 如果Ti=3T_i = 3:表示询问用户AiA_i和用户BiB_i是否互相关注。若用户AiA_i关注用户BiB_i且用户BiB_i也关注用户AiA_i,则输出Yes;否则,输出No

当服务刚上线时,没有任何用户关注其他用户。

请按照ii的升序依次打印出所有Ti=3T_i = 3对应的操作所要求的答案。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Takahashi runs an SNS "Twidai," which has NN users from user 11 through user NN. In Twidai, users can follow or unfollow other users.

QQ operations have been performed since Twidai was launched. The ii-th (1iQ)(1\leq i\leq Q) operation is represented by three integers TiT_i, AiA_i, and BiB_i, whose meanings are as follows:

  • If Ti=1T_i = 1: it means that user AiA_i follows user BiB_i. If user AiA_i is already following user BiB_i at the time of this operation, it does not make any change.
  • If Ti=2T_i = 2: it means that user AiA_i unfollows user BiB_i. If user AiA_i is not following user BiB_i at the time of this operation, it does not make any change.
  • If Ti=3T_i = 3: it means that you are asked to determine if users AiA_i and BiB_i are following each other. You need to print Yes if user AiA_i is following user BiB_i and user BiB_i is following user AiA_i, and No otherwise.

When the service was launched, no users were following any users.

Print the correct answers for all operations such that Ti=3T_i = 3 in ascending order of ii.

Constraints

  • 2N1092 \leq N \leq 10 ^ 9
  • 1Q2×1051 \leq Q \leq 2\times10 ^ 5
  • Ti=1,2,3 (1iQ)T _ i=1,2,3\ (1\leq i\leq Q)
  • 1AiN (1iQ)1 \leq A _ i \leq N\ (1\leq i\leq Q)
  • 1BiN (1iQ)1 \leq B _ i \leq N\ (1\leq i\leq Q)
  • AiBi (1iQ)A _ i\neq B _ i\ (1\leq i\leq Q)
  • There exists i (1iQ)i\ (1\leq i\leq Q) such that Ti=3T _ i=3.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN QQ

T1T _ 1 A1A _ 1 B1B _ 1

T2T _ 2 A2A _ 2 B2B _ 2

\vdots

TQT _ Q AQA _ Q BQB _ Q

Output

Print XX lines, where XX is the number of ii's (1iQ)(1\leq i\leq Q) such that Ti=3T _ i=3. The jj-th (1jX)(1\leq j\leq X) line should contain the answer to the jj-th operation such that Ti=3T _ i=3.

Sample Input 1

3 9
1 1 2
3 1 2
1 2 1
3 1 2
1 2 3
1 3 2
3 1 3
2 1 2
3 1 2

Sample Output 1

No
Yes
No
No

Twidai has three users. The nine operations are as follows.

  • User 11 follows user 22. No other users are following or followed by any users.
  • Determine if users 11 and 22 are following each other. User 11 is following user 22, but user 22 is not following user 11, so No is the correct answer to this operation.
  • User 22 follows user 11.
  • Determine if users 11 and 22 are following each other. User 11 is following user 22, and user 22 is following user 11, so Yes is the correct answer to this operation.
  • User 22 follows user 33.
  • User 33 follows user 22.
  • Determine if users 11 and 33 are following each other. User 11 is not following user 33, and user 33 is not following user 11, so No is the correct answer to this operation.
  • User 11 unfollows user 22.
  • Determine if users 11 and 22 are following each other. User 22 is following user 11, but user 11 is not following user 22, so No is the correct answer to this operation.

Sample Input 2

2 8
1 1 2
1 2 1
3 1 2
1 1 2
1 1 2
1 1 2
2 1 2
3 1 2

Sample Output 2

Yes
No

A user may follow the same user multiple times.

Sample Input 3

10 30
3 1 6
3 5 4
1 6 1
3 1 7
3 8 4
1 1 6
2 4 3
1 6 5
1 5 6
1 1 8
1 8 1
2 3 10
1 7 6
3 5 6
1 6 7
3 6 7
1 9 5
3 8 6
3 3 8
2 6 9
1 7 1
3 10 8
2 9 2
1 10 9
2 6 10
2 6 8
3 1 6
3 1 8
2 8 5
1 9 10

Sample Output 3

No
No
No
No
Yes
Yes
No
No
No
Yes
Yes

update @ 2024/3/10 11:42:15