아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Point Pairs

시간 제한1.5초메모리 제한256 MB

요약
점 2N+1개 중 하나를 제거한 뒤 남은 2N개를 같은 x좌표나 y좌표를 공유하는 쌍으로 묶을 수 있는지 각 점마다 판정한다.
난이도

보통10점 중 7점

유형
그래프, 그리디, 해시맵
정답자
아직 제출이 없습니다

문제

There are 2N+12N+1 points on a plane. The ii-th point is at (X_i,Y_i)(X\_i, Y\_i). Two points ii and jj can be paired if X_i=X_jX\_i = X\_j or Y_i=Y_jY\_i = Y\_j.

For each point, determine the following:

  • If you remove this point from the set of points, you get 2N2N points. Can these 2N2N points be separated into NN disjoint pairs?

입력

NN
X_1X\_1 Y_1Y\_1
X_2X\_2 Y_2Y\_2
⋮\vdots
X_2N+1X\_{2N+1} Y_2N+1Y\_{2N+1}

출력

Output 2N+12N+1 lines. For the ii-th line, print "OK" if all points except for the ii-th can be separated into NN disjoint pairs. Otherwise print "NG".

제한

  • 1≤N≤100,0001 \leq N \leq 100,000
  • 1≤X_i,Y_i≤2N+11 \leq X\_i, Y\_i \leq 2N+1
  • The points are pairwise distinct.
  • All values in the input are integers.

예제3

  1. 예제 1

    입력
    1
    1 1
    1 2
    2 1
    
    예상 출력
    NG
    OK
    OK
    
  2. 예제 2

    입력
    2
    1 1
    1 2
    2 2
    2 3
    3 3
    
    예상 출력
    OK
    NG
    OK
    NG
    OK
    
  3. 예제 3

    입력
    2
    1 1
    1 2
    3 3
    4 4
    4 5
    
    예상 출력
    NG
    NG
    OK
    NG
    NG