Three in line P96191


Statement
 

pdf   zip

Consider an n×nn \times n integer grid with exactly 2n2n points marked on it. Can you find three points in the same line?

Input

Input consists of several cases, each with nn, followed by 2n2n pairs (x,y)(x, y). Assume 3n1053 \le n \le 10^5, that xx and yy are integer numbers between 1 and nn, and that there are no repeated points.

Output

Print a line for every case. If there are no three (or more) points in any line, print “NO”. Otherwise, print “YES” followed by the three points that you found, in any order. If there is more than one solution, you can print any one. Follow strictly the format of the sample output.

Observation

The “large” private test cases were generated at random, by picking both xx and yy uniformly and independently, and descarting repeated points until having 2n2n in total.

Public test cases
  • Input

    3  1 1  2 2  3 3  1 3  3 1  1 2
    3  1 1  2 2  3 3  1 3  3 1  1 2
    4  1 1  1 2  2 3  2 4  3 1  3 2  4 3  4 4
    

    Output

    YES  2 2  3 3  1 1
    YES  1 1  1 3  1 2
    NO
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++