E. Envy(可撤销并查集+离线处理)

这篇博客讨论了在连接的无向加权图中,最小生成树(MST)的概念及其在解决图论问题中的重要性。文章指出,当在图上运行MST算法时,可能会导致某些边变得'嫉妒',因为它们没有被选入MST。接下来,博主提出了一个包含多个查询的问题,每个查询涉及图中的一组边,要求判断是否存在一个MST包含这些边。题目给出了图的顶点数、边数和查询数,并对边的权重和重复性进行了描述。对于每个查询,需要确定是否存在包含这些边的MST,并分别以'YES'或'NO'作答。
摘要由CSDN通过智能技术生成
E. Envy
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

For a connected undirected weighted graph G, MST (minimum spanning tree) is a subgraph of G that contains all of G's vertices, is a tree, and sum of its edges is minimum possible.

You are given a graph G. If you run a MST algorithm on graph it would give you only one MST and it causes other edges to become jealous. You are given some queries, each query contains a set of edges of graph G, and you should determine whether there is a MST containing all these edges or not.

Input

The first line contains two integers n, m (2  ≤ n, m  ≤ 5·105, n - 1 ≤ m) — the number of vertices and edges in the graph and the number of queries.

The i-th of the next m lines contains three integers u<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值