#P13585. [NWRRC 2023] Every Queen
[NWRRC 2023] Every Queen
题目描述
There are chess queens on an infinite grid. They are placed in squares with coordinates . Your task is to find a square that all queens attack, or report that no such square exists.
A queen in square attacks square if at least one of the following conditions is satisfied:
- ;
- ;
- .
Note that in this problem, the queens do not block each other. For example, if there are queens in squares and , both of them attack square . Moreover, you can choose a square that already contains a queen. For example, square would be a valid answer in this case.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer , denoting the number of queens ().
The -th of the following lines contains two integers and , denoting the coordinates of the square containing the -th queen (). No two queens share the same square.
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, if an answer exists, print in the first line. Then, in the second line, print two integers and , denoting the coordinates of a square attacked by every queen ().
If no such square exists, print a single line containing instead.
It can be shown that if an answer exists, there also exists an answer that satisfies . If there are multiple answers, print any of them.
3
2
1 1
2 2
4
0 1
1 0
3 1
4 0
5
0 1
1 0
1 2
2 2
4 2
YES
1 1
NO
YES
-1 2