题意翻译
题目大意:
有一棵树,现在给你每条树边被去掉时,形成的两个联通块中点的最大的编号分别是多少,问满足条件的树存不存在
输入格式:
第一行一个整数nnn
往下n−1n-1n−1行,每行两个整数,表示去掉这条边后两个联通块中点的最大的编号是多少
输出格式:
如果不存在满足条件的树,输出"NO"
否则输出"YES",下面n−1n-1n−1行每行描述一条树边(两端点的编号)
题目描述
Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from 1 1 1 to n n n . For every edge e e e of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge e e e (and only this edge) is erased from the tree.
Monocarp has given you a list of n−1 n - 1 n−1 pairs of numbers. He wants you to provide an example of a tree that will produce the said list if this tree exists. If such tree does not exist, say so.
输入输出格式
输入格式:
The first line contains one integer n n n ( 2≤n≤1000 2 \le n \le 1\,000 2≤n≤1000 ) — the number of vertices in the tree.
Each of the next n−1 n-1 n−1 lines contains two integers ai a_i ai and bi b_i bi each ( 1≤ai<bi≤n 1 \le a_i < b_i \le n 1≤ai<bi≤n ) — the maximal indices of vertices in the