#P1822. Who's Opposite
Who's Opposite
题目描述
Click here to read PDF of this problem
输入格式
As shown in the PDF.
输出格式
As shown in the PDF
样例
7
6 2 4
2 3 1
2 4 10
5 3 4
1 3 2
2 5 4
4 3 2
8
-1
-1
-1
4
1
-1
提示
Note In the first test case, there's a desired circle of 8 people. The person with the number 6 will look at the person with the number 2 and the person with the number 8 will look at the person with the number 4.
In the second test case, there's no circle meeting the conditions. If the person with the number 2 is looking at the person with the number 3, the circle consists of 2 people because these persons are neighbors. But, in this case, they must have the numbers 1 and 2, but it doesn't meet the problem's conditions.
In the third test case, the only circle with the persons with the numbers 2 and 4 looking at each other consists of 4 people. Therefore, the person with the number 10 doesn't occur in the circle.
Codeforces Round #739 (Div. 3) B题
Input by QLU_张席畅