atcoder#ABC235E. [ABC235E] MST + 1
[ABC235E] MST + 1
Score : points
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
.
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
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.
2 3 2
1 2 100
1 2 1000000000
1 1 1
1 2 2
1 1 5
Yes
No