F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Divide and Conquer

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 404    Accepted Submission(s): 82
Special Judge


Problem Description
Given $n$ points in 2D plane, where $n \equiv 0 \pmod{4}$, no two points coincide and no three points are collinear. Find two intersecting lines satisfying that no given points lie in the two lines and that for each of the four divided areas, there are exactly $\frac{n}{4}$ given points. If multiple solutions exist, print any one of them. If no solution, print "-1" in one line.
 

Input
The first line contains one positive integer $T$ ($1\le T \le 20$), denoting the number of test cases. For each test case:

The first line contains one integer $n\,(4 \le n \le 50000)$, denoting the number of given points.

Following $n$ lines each contains two integers $x_i, y_i\,(|x_i|, |y_i| \le 10^6)$, denoting one given point $(x_i, y_i)$.

It is guaranteed that $\sum n \le 10^5, \, n \equiv 0 \pmod{4}$, that no two points coincide and that no three points are collinear.
 

Output
For each test case:

If no solution, print "-1" in one line. Else print two lines each containing four integers $x_1, y_1, x_2, y_2 \, ((x_1, y_1) \neq (x_2, y_2))$ with absolute value not exceeding $10^9$, denoting one line passing $(x_1, y_1), (x_2, y_2)$ simultaneously.
 

Sample Input
2 4 -1 -1 -1 1 1 -1 1 1 8 0 0 0 1 2 0 2 1 1 2 1 3 3 2 3 3
 

Sample Output
0 1 0 -1 1 0 -1 0 1 0 2 3 0 2 3 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 03:15:37, Gzip enabled