#P6971. [NEERC2016] Jenga Boom
[NEERC2016] Jenga Boom
题目描述
Jane is a game designer and she designs the next version of Jenga Boom, where the blocks have dimensions of instead of the ordinary . As usual, the initial tower is created at the game start. It consists of the blocks in levels of 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 and . 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 and that define the dimensions of the block as described in the problem statement . The second line also contains two integers: -- the number of levels in the tower and -- the number of removed blocks .
The next lines contain coordinates of the removed blocks with two integers each: -- the level of the block, counting from the bottom and -- the position of the block, counting from the edge nearest to the players ; . 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 ) , that was removed just before the collapse, in the next line.
题目大意
设有一个塔,它的积木块是 的长方体,每层由 个积木块,每两层交错摆放,共有 层。有 个抽积木的操作,对于第 个操作给出从底往上数的第 层和从左后方往右前方数的第 块。某一层的左边或右边加上中间 (如果 为偶数,那么忽略中间) 的积木块全被抽完,则塔倒塌。
输入格式
第一行为 和 ,() 。第二行为 和 ,()。接下来的 行为 和 () 。一块积木只能移动一次。
输出格式
如果塔能倒塌,则输出 "yes" 。否则输出 "no" 。对于第一种情况,在下一行输出倒塌前一步的编号 。
5 2
6 6
4 1
4 2
4 5
5 3
4 3
1 1
yes
5
3 3
10 1
10 3
no
2 2
2 1
1 1
yes
1
提示
Time limit: 2 s, Memory limit: 512 MB.