2023夏-A-4 Big Number
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
题目描述
How to generate a big number of digits randomly? One way is to find kids, give each one a card with one's index written on one side (hence it is assumed that the kids are indexed from 1 to ), and ask them to write down a 1-digit number randomly on the other side. Then let the kids pin their digits in a line, on the wall, one by one in ascending order of their indices.
However, it's very difficult to let hundreds of thousands of kids to follow the order. The result is that we have cards pinned randomly all over the wall, some even show the wrong sides. For example, if the 23rd kid has written down 8, we are supposed to find the number 8 on the wall. But instead we might find 23... Your job is to rearrange these cards so that we can obtain the big number as required.
输入格式
Each input file contains one test case. For each case, the first line gives a positive integer (). Then lines follow, each describes a card in the format n1 n2 where the two numbers are the numbers written on the two sides of a card.
输出格式
For each test case, print in a line the -digit number as required. That is, print the digits written by the kids in ascending order of their indices. In case that there are 1-digit numbers written on both sides, it would be hard to tell which one is the index and which one is the number written by the kid. Hence the solution may not be unique. In this case, just output the smallest resulting number.
It is guaranteed that a solution exists.
样例
12
7 11
8 9
3 1
2 12
4 6
10 0
5 1
2 5
6 8
1 4
7 2
9 3
359114268072
限制
对于所有的测试用例,限制为400ms, 64MB