ABC422E.E - Colinear

传统题 时间 2000 ms 内存 256 MiB 7 尝试 2 已通过 2 标签

E - Colinear

Score : 450450 points

Problem Statement

There are NN points on a two-dimensional plane. NN is odd. The ii-th point is at (x_i,y_i)(x\_i, y\_i). All point coordinates are distinct.

Determine whether there exists a line passing through more than half of the NN points, and if so, output it.

For any input satisfying the constraints, if a line satisfying the condition exists, it can be expressed as ax+by+c=0ax+by+c=0 using integers a,b,ca,b,c with −1018≤a,b,c≤1018-10^{18} \leq a,b,c \leq 10^{18} (where (a,b,c)≠(0,0,0)(a,b,c) \neq (0,0,0)). Output these a,b,ca,b,c.

Constraints

  • 3≤N≤5×1053 \leq N \leq 5 \times 10^5
  • NN is odd.
  • −108≤x_i≤108-10^8 \leq x\_i \leq 10^8
  • −108≤y_i≤108-10^8 \leq y\_i \leq 10^8
  • If i≠ji \neq j, then (x_i,y_i)≠(x_j,y_j)(x\_i, y\_i) \neq (x\_j, y\_j).
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

$N$
$x_1$ $y_1$
$x_2$ $y_2$
$\vdots$
$x_N$ $y_N$

Output

If no line satisfying the condition exists, output No.

If a line satisfying the condition exists, output two lines. On the first line, output Yes, and on the second line, output a,b,ca,b,c in this order separated by spaces. a,b,ca,b,c must satisfy −1018≤a,b,c≤1018-10^{18} \leq a,b,c \leq 10^{18} and (a,b,c)≠(0,0,0)(a,b,c) \neq (0,0,0).

If there are multiple solutions, any of them will be considered correct.


The line 2x+y−8=02x+y-8=0 passes through the 22nd and 33rd points, so it satisfies the condition.


No line satisfying the condition exists.


Samples

3
1 1
3 2
2 4
Yes
2 1 -8
5
5 2
1 3
2 6
4 4
5 4
No
11
-9374372 85232388
-60705467 86198234
-7475320 80628487
98066347 -23868213
-12177678 85284287
30535572 -35358356
51324557 22410787
28854279 44658587
-28804873 82911971
65052073 8819187
-67744430 68365758
Yes
4655800 4702358 -344340416016346

在线编程 IDE

建议全屏模式获得最佳体验