问题 A: Magma Cave

内存限制:128 MB 时间限制:12 S
题面:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

Little Q is researching an active volcano. There are n caves inside the volcano, labeled by 1,2,,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:

  • ''1 u v w'' (1u,vn, uv1wq): 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.
  • ''2 k w'' (1k<n1wq): 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.

输入格式

The first line contains a single integer T (1T100), the number of test cases. For each test case:

The first line contains two integers n and q (2n50,0001q200,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.

输出格式

For each question, print a single line. If it is possible, print ''YES'', otherwise print ''NO''.

输入样例 复制

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

输出样例 复制

NO
YES
YES
NO
YES
YES

分类标签