|
||||||||||
Magma CaveTime Limit: 12000/12000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 171 Accepted Submission(s): 66 Problem Description Little Q is researching an active volcano. There are $n$ caves inside the volcano, labeled by $1,2,\dots,n$. At the very beginning, before the first volcanic activity event, there is no magma path between these caves. You will be given $q$ operations, each operation is one of the following: - ''$\texttt{1 u v w}$'' ($1 \leq u,v \leq n$, $u\neq v$, $1\leq w\leq q$): A volcanic activity event comes such that a new magma path between the $u$-th cave and the $v$-th cave occurs, whose length is $w$. Here $w$ is used for identifying the magma path, so $w$ will always be pairwise different. - ''$\texttt{2 k w}$'' ($1 \leq k< n$, $1\leq w\leq q$): Assume it is a undirected graph with $n$ vertices, each magma path denoting an edge, Little Q is wondering whether there exists a spanning tree whose $k$-th shortest edge is of length $w$. You are the partner of Little Q, please write a program to answer his question. Input The first line contains a single integer $T$ ($1 \leq T \leq 100$), the number of test cases. For each test case: The first line contains two integers $n$ and $q$ ($2 \leq n \leq 50\,000$, $1\leq q\leq 200\,000$), denoting the number of caves and the number of operations. Each of the next $q$ lines describes an operation in formats described in the statement above. It is guaranteed that the sum of all $n$ is at most $300\,000$, and the sum of all $q$ is at most $1\,000\,000$. Output For each question, print a single line. If it is possible, print ''$\texttt{YES}$'', otherwise print ''$\texttt{NO}$''. Sample Input
Sample Output
Source | ||||||||||
|