QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 512 MB Total points: 100

#12543. 层层叠爆炸

Statistics

Jane 是一位游戏设计师,她正在设计新版本的 Jenga Boom,其中积木的尺寸为 $1 \times w \times wn$,而不是普通的 $1 \times 2 \times 6$。和往常一样,初始塔在游戏开始时创建。它由 $n$ 个积木组成的若干层构成,每层积木沿长边并排摆放,且与上一层呈直角。玩家轮流从塔中移除积木,直到塔倒塌。

初始塔

倒塌前的塔

Jane 想要构建一个游戏模拟器,帮助她决定最佳的 $n$ 和 $w$。模拟器需要计算如果按照指定的顺序移除积木,塔会在何时倒塌。如果层与层之间存在一个横截面,使得其上方所有层的重心不属于(或位于)其下方一层的投影的凸包边缘,则塔会倒塌。

输入格式

第一行包含两个整数 $n$ 和 $w$,定义了题目描述中积木的尺寸 ($1 \le n, w \le 10\,000$)。第二行包含两个整数:$h$ — 塔的层数,$m$ — 移除积木的数量 ($1 \le h, m \le 5\,000$)。

接下来的 $m$ 行包含移除积木的坐标,每行两个整数:$l_i$ — 积木所在的层数(从底部开始计数),$k_i$ — 积木的位置(从离玩家最近的边缘开始计数)($1 \le l_i \le h; 1 \le k_i \le n$)。积木被逐个移除,且没有积木会被移除两次。

输出格式

如果塔倒塌,第一行输出 “yes”,否则输出 “no”。如果是前者,在下一行输出在倒塌前刚刚被移除的积木编号(从 1 开始计数)。

样例

输入 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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.