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

13744번 - Illumination 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB136766457.658%

문제

You inherited a haunted house. Its floor plan is an n-by-n square grid with l lamps in fixed locations and no interior walls. Each lamp can either illuminate its row or its column, but not both simultaneously. The illumination of each lamp extends by r squares in both directions, so a lamp unobstructed by an exterior wall of the house can illuminate as many as 2r + 1 squares.

If a square is illuminated by more than one lamp in its row, or by more than one lamp in its column, the resulting bright spot will scare away ghosts forever, diminishing the value of your property. Is it possible for all lamps to illuminate a row or column, without scaring any ghosts? Note that a square illuminated by two lamps, one in its row and the other in its column, will not scare away the ghosts.

입력

The first line of input contains three positive integers, n, r and l (1 ≤ n, r, l ≤ 1,000).

Each of the next l lines contains two positive integers ri and ci (1 ≤ ri, ci ≤ n), indicating that there is a lamp in row ri and column ci.

It is guaranteed that all lamps are in distinct locations.

출력

Print, on a single line, 1 if it is possible to illuminate all lamps as stated above; otherwise, print 0.

제한

예제 입력 1

3 2 5
1 1
1 3
3 1
3 3
2 2

예제 출력 1

1

예제 입력 2

3 2 6
1 1
1 2
1 3
3 1
3 2
3 3

예제 출력 2

0

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2016 Southeast USA Regional Programming Contest > Division 1 E번

ICPC > Regionals > North America > Pacific Northwest Regional > 2016 Pacific Northwest Region Programming Contest > Division 1 F번

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

출처

대학교 대회

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

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