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

13998번 - Jenga Boom 다국어

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

문제

Jane is a game designer and she designs the next version of Jenga Boom, where the blocks have dimensions of 1×w ×wn instead of the ordinary 1×2×6. As usual, the initial tower is created at the game start. It consists of the blocks in levels of n blocks placed next to each other along their long sides and at a right angle to the previous level. Players remove blocks from the tower in turns, until the tower collapses.


Initial tower


The tower before collapse

Jane wants to build a game simulator that helps her to decide the best n and w. The simulator shall compute the moment when the tower collapses if blocks are removed in the specified order. Tower collapses if there is a cross-section between levels such that the center of the mass of the levels above it does not belong to or is at the edge of the convex hull of the previous level projection.

입력

The first line contains two integers n and w that define the dimensions of the block as described in the problem statement (1 ≤ n, w ≤ 10 000). The second line also contains two integers: h — the number of levels in the tower and m — the number of removed blocks (1 ≤ h, m ≤ 5 000).

The next m lines contain coordinates of the removed blocks with two integers each: li — the level of the block, counting from the bottom and ki — the position of the block, counting from the edge nearest to the players (1 ≤ li ≤ h; 1 ≤ ki ≤ n). Blocks are removed one by one and no block is removed twice.

출력

In the first line output “yes” if the tower collapses, and “no” otherwise. In the former case, output the number of the block (starting from 1), that was removed just before the collapse, in the next line.

제한

예제 입력 1

5 2
6 6
4 1
4 2
4 5
5 3
4 3
1 1

예제 출력 1

yes
5

예제 입력 2

3 3
10 1
10 3

예제 출력 2

no

예제 입력 3

2 2
2 1
1 1

예제 출력 3

yes
1

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > NEERC 2016 J번

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

출처

대학교 대회

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

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