#C3006. Unique Minimum Spanning Tree

    ID: 46386 Type: Default 1000ms 256MiB

Unique Minimum Spanning Tree

Unique Minimum Spanning Tree

You are given an undirected weighted graph. The graph is specified by the number of nodes and edges, and the list of roads connecting nodes. Each road is given by three integers u, v, and w, representing an edge between node u and node v with weight w.

Your task is to determine whether the graph has a unique Minimum Spanning Tree (MST). A sufficient condition for the MST to be unique is that all edge weights in the graph are distinct. In this problem, you can assume that if any duplicate weight exists, the MST is not unique; otherwise, if all edge weights are unique, then the MST is unique.

Note: The input graph might be empty. In that case, the graph is considered to have a unique MST.

The input is provided via standard input and the output should be printed to standard output.

The answer should be YES if the graph has a unique MST, and NO otherwise.

inputFormat

The first line contains two integers n and m, separated by a space, where n is the number of nodes and m is the number of edges in the graph.

This is followed by m lines. Each of these lines contains three integers u v w, where u and v denote an edge between nodes u and v, and w is the weight of the edge.

You can assume that the nodes are numbered from 1 to n. In the case of an empty graph, n and m will be 0.

outputFormat

Output a single line containing YES if the graph has a unique MST, or NO otherwise.

## sample
4 4
1 2 3
2 3 2
3 4 1
4 1 4
YES