Logo
(追記) (追記ここまで)

19520번 - Point Pairs 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 256 MB31131050.000%

문제

There are 2ドルN+1$ points on a plane. The $i$-th point is at $(X_i, Y_i)$. Two points $i$ and $j$ can be paired if $X_i = X_j$ or $Y_i = Y_j$.

For each point, determine the following:

  • If you remove this point from the set of points, you get 2ドルN$ points. Can these 2ドルN$ points be separated into $N$ disjoint pairs?

입력

$N$
$X_1$ $Y_1$
$X_2$ $Y_2$
$\vdots$
$X_{2N+1}$ $Y_{2N+1}$

출력

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

제한

  • 1ドル \leq N \leq 100,000$
  • 1ドル \leq X_i, Y_i \leq 2N+1$
  • The points are pairwise distinct.
  • All values in the input are integers.

예제 입력 1

1
1 1
1 2
2 1

예제 출력 1

NG
OK
OK

예제 입력 2

2
1 1
1 2
2 2
2 3
3 3

예제 출력 2

OK
NG
OK
NG
OK

예제 입력 3

2
1 1
1 2
3 3
4 4
4 5

예제 출력 3

NG
NG
OK
NG
NG

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2016 > Day 9: Grand Prix of Japan B번

Contest > Open Cup > 2016/2017 Season > Stage 1: Grand Prix of Japan B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /