#abc235e. E - MST + 1
E - MST + 1
Score : points
问题描述
给定一个带权重的无向连通图 ,包含 个顶点和 条边,该图可能包含自环和平行边。 顶点被标记为顶点 、顶点 、、顶点 。 边被标记为边 、边 、、边 。边 连接顶点 和顶点 ,其权重为 。这里对于任意一对整数 满足 ,有 。
处理以下 个查询:
第 个查询给出一个三元组 。这里对于任意整数 满足 ,有 。
令 表示连接顶点 和顶点 、权重为 的无向边。考虑通过在 中添加 得到的图 。可以证明 的最小生成树 是唯一确定的。问 是否包含边 ?打印答案 Yes
或 No
。
注意:查询不会改变原始的 。换句话说,尽管第 个查询考虑了通过在 中添加 得到的图,但在其他查询中的 不包含 。
什么是最小生成树? 生成树 是 中包含所有顶点及部分边构成的一棵树。 最小生成树 是 的生成树中具有最小总边权重的那棵树。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is a weighted undirected connected graph with vertices and edges, which may contain self-loops and multi-edges.
The vertices are labeled as Vertex , Vertex , , Vertex .
The edges are labeled as Edge , Edge , , Edge . Edge connects Vertex and Vertex and has a weight of . Here, for every pair of integers such that , holds.
Process the queries explained below.
The -th query gives a triple of integers . Here, for every integer such that , holds.
Let be an undirected edge that connects Vertex and Vertex and has a weight of . Consider the graph obtained by adding to . It can be proved that the minimum spanning tree of is uniquely determined. Does contain ? Print the answer as Yes
or No
.
Note that the queries do not change . In other words, even though Query considers the graph obtained by adding to , the in other queries does not have .
What is minimum spanning tree? The spanning tree of is a tree with all of the vertices in and some of the edges in .
The minimum spanning tree of is the tree with the minimum total weight of edges among the spanning trees of .
Constraints
- The graph is connected.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer to Query : Yes
or No
.
Sample Input 1
5 6 3
1 2 2
2 3 3
1 3 6
2 4 5
4 5 9
3 5 8
1 3 1
3 4 7
3 5 7
Sample Output 1
Yes
No
Yes
Below, let denote an undirected edge that connects Vertex and Vertex and has the weight of . Here is an illustration of :
For example, Query considers the graph obtained by adding to . The minimum spanning tree of has the edge set , which contains , so Yes
should be printed.
Sample Input 2
2 3 2
1 2 100
1 2 1000000000
1 1 1
1 2 2
1 1 5
Sample Output 2
Yes
No
update @ 2024/3/10 10:12:23