Dominoes!官方中文
题目描述
官方中文Dominoes are rectangular tiles made of wood, bone, or plastic. They are arranged in a line at a certain distance from each other, and when the first tile is lightly tipped over, the rest of the tiles fall in succession, creating a chain reaction. However, now you want to use the dominoes to play a different game. Given
$n$ dominoes, each domino has two positive integers between $1$ and $10^9$ written on it. You need to arrange these dominoes in a horizontal line so that each end of a domino matches the end of the adjacent domino (except for the two ends of the line). When arranging the dominoes, you can choose either number to be on the left or right. The task is to determine if there is an arrangement where the numbers at the touching ends of adjacent dominoes are always different. If such an arrangement exists, provide a possible solution.官方中文
输入格式
官方中文The first line of input contains an integer $n$ $(1\leq n\leq 2\times 10^5)$, denoting the number of dominoes.官方中文
Then $n$ lines follow. The $i$-th $(1\leq i\leq n)$ line contains two integers $x_i,y_i$ $(1\leq x_i,y_i\leq 10^9)$, denoting the numbers written on the $i$-th domino.官方中文
输出格式
官方中文If there exists a valid way to arrange dominoes, output "Yes" in the first line (without quotes). Otherwise, output ``No'' in the first line (without quotes). You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will all be considered as positive replies.官方中文
If your answer is "Yes", you need to output two numbers $x_i, y_i$ in the next $n$ lines, where the $i$-th ($1 \leq i \leq n$) line represents the numbers on the left and right sides of the $i$-th domino in your solution, arranged from left to right.官方中文
样例
3
1 2
2 3
3 1Yes
1 2
3 2
3 13
1 1
1000000000 1000000000
1000000000 1000000000Yes
1000000000 1000000000
1 1
1000000000 10000000002
2 2
2 2No题面与样例版权归 牛客竞赛 及出题人所有;中文翻译由 AI 生成(官方原文),如有出入请以原文为准。