问题 D: Chaos Begin

内存限制:128 MB 时间限制:15 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:5 通过:1

题目描述

Long long ago, there were n points a1,a2,,an on the 2D plane. The world keeps stable for a long time. However, it begins to be chaotic recently when another n points b1,b2,,bn appeared, where bi=ai+(Δx,Δy). And now, these 2n points have already lost their identifiers.

You are given these 2n points in an arbitrary order, you need to figure out all the possible (Δx,Δy) to help the world recover from chaos.

输入格式

The first line contains a single integer T (1T100), the number of test cases. For each test case:

The first line of the input contains a single integer n (1n50,000), denoting the number of initial points.

In the next 2n lines, the i-th line contains two integers xi and yi (xi,yi≤1e8), describing the coordinate of a current point.

It is guaranteed that the x-coordinate and y-coordinate of each initial point are chosen uniformly at random from integers in [v,v], where v is chosen in [1e7,1e8]. The randomness condition does not apply to the sample test case, but your solution must pass the sample as well.

It is also guaranteed that the sum of all n is at most 300,000.

输出格式

For each test case, first output a single line containing an integer k, denoting the number of possible (Δx,Δy). Then output k lines, each line contains two integers Δx and Δy. It is guaranteed that k1, and when k2, you should print the answers in ascending order of Δx, and then in ascending order of Δy in case of a tie.

输入样例 复制

1
3
1 2
3 4
8 9
7 8
6 7
2 3

输出样例 复制

2
-5 -5
5 5

分类标签