QOJ.ac

QOJ

حد الوقت: 12 s حد الذاكرة: 512 MB مجموع النقاط: 100

#6872. 岩浆洞穴

الإحصائيات

Little Q 正在研究一座活火山。火山内部有 $n$ 个洞穴,编号为 $1, 2, \dots, n$。在最开始,即第一次火山活动事件发生前,这些洞穴之间没有任何岩浆路径。你将收到 $q$ 次操作,每次操作属于以下两种类型之一:

  • “1 $u$ $v$ $w$” ($1 \le u, v \le n, u \neq v, 1 \le w \le q$):发生了一次火山活动事件,在第 $u$ 个洞穴和第 $v$ 个洞穴之间出现了一条长度为 $w$ 的新岩浆路径。此处 $w$ 用于标识该岩浆路径,因此 $w$ 总是两两不同的。
  • “2 $k$ $w$” ($1 \le k < n, 1 \le w \le q$):假设这是一个包含 $n$ 个顶点的无向图,每条岩浆路径代表一条边,Little Q 想知道是否存在一棵生成树,其第 $k$ 短的边长度为 $w$。你是 Little Q 的伙伴,请编写一个程序来回答他的问题。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 100$),表示测试用例的数量。对于每个测试用例:

第一行包含两个整数 $n$ 和 $q$ ($2 \le n \le 50\,000, 1 \le q \le 200\,000$),分别表示洞穴的数量和操作的数量。

接下来的 $q$ 行,每行描述一个操作,格式如上所述。

保证所有测试用例的 $n$ 之和不超过 $300\,000$,所有测试用例的 $q$ 之和不超过 $1\,000\,000$。

输出格式

对于每个询问,输出一行。如果存在这样的生成树,输出 “YES”,否则输出 “NO”。

样例

输入 1

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

输出 1

NO
YES
YES
NO
YES
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.