Codeforces Round 990 (Div. 1)
C
Adventurers
Codeforces
2100
原题
← BD →
翻译中…

Once, four Roman merchants met in a Roman mansion to discuss their trading plans. They faced the following problem: they traded the same type of goods, and if they traded in the same city, they would inevitably incur losses. They decided to divide up the cities between them where they would trade.

翻译中…

The map of Rome can be represented in this problem as a plane with certain points marked — the cities of the Roman Empire.

翻译中…

The merchants decided to choose a certain dividing point $(x_0, y_0)$. Then, in a city with coordinates $(x_i, y_i)$,

翻译中…
  • the first merchant sells goods if $x_0 \le x_i$ and $y_0 \le y_i$;
  • the second merchant sells goods if $x_0 \gt x_i$ and $y_0 \le y_i$;
  • the third merchant sells goods if $x_0 \le x_i$ and $y_0 \gt y_i$;
  • the fourth merchant sells goods if $x_0 \gt x_i$ and $y_0 \gt y_i$.
翻译中…

The merchants want to choose $(x_0, y_0)$ in such a way as to maximize the smallest number of cities that any of them gets (i. e., as fair as possible). Please find such a point for them.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($4 \le n \le 10^5$) — the number of cities on the map.

翻译中…

Each of the next $n$ lines contains two integers $x_i, y_i$ ($-10^9 \le x_i, y_i \le 10^9$) — the coordinates of the cities.

翻译中…

Note that some points may coincide. This is because some cities may be so close that they cannot be distinguished on the map at the given scale.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.

翻译中…

Output

翻译中…

For each test case, in the first line, print a single integer $k$ ($0 \le k \le \frac{n}{4}$) — the maximum possible number of cities that each merchant can get at a minimum.

翻译中…

In the second line, print two integers $x_0$ and $y_0$ ($|x_0|, |y_0| \le 10^9$) — the coordinates of the dividing point. If there are multiple suitable points, print any of them.

翻译中…

样例

Input #1
4
4
1 1
1 2
2 1
2 2
4
0 0
0 0
0 0
0 0
8
1 2
2 1
2 -1
1 -2
-1 -2
-2 -1
-2 1
-1 2
7
1 1
1 2
1 3
1 4
2 1
3 1
4 1
Output #1
1
2 2
0
0 0
2
1 0
0
0 0
InputCopy OutputCopy
题目信息
题号
2046C
时间限制
3 s
内存限制
256 MB
标签
二分
数据结构
贪心
排序
三分
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。