QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 2048 MB 總分: 100

#2313. 无聊的游戏

统计

暑假刚刚开始,你昨天刚回到家。更好的是,你刚入手了 Ubihard 新出的游戏。游戏讲述了创世的故事,而你将成为造物主。众所周知,在时间之初,在创造任何生物之前,造物主首先要做的是创造雨滴。另一方面,显然有一个破坏者会阻止世界的形成。(我知道这游戏很无聊,但你对 Ubihard 能有什么期待呢?)。游戏发生在一个二维平面上,并被限制在一个左下角为 $(0, 0)$、右上角为 $(n, m)$ 的矩形区域内。$x$ 轴代表地面。规则如下:

  • 造物主可以在给定的框架内选择一个整数坐标点 $(x, y)$(其中 $x, y \in \mathbb{Z}, 0 \le x \le n, 0 \le y \le m$)并在此处创造一个雨滴。然后,造物主将获得 $y$ 点积分。
  • 破坏者可以在给定的框架内创建水平条,以防止雨滴接触地面。一个条可以表示为以两个端点 $(x_1, y)$ 和 $(x_2, y)$ 为界的线段(其中 $0 \le x_1 < x_2 \le n, 0 \le y \le m, x_1, x_2, y \in \mathbb{Z}$)。创建后,该条将在游戏的剩余时间内一直存在。如果雨滴是在条的上方产生的,它将无法到达地面。也就是说,如果存在一个端点为 $(x_1, y)$ 和 $(x_2, y)$ 的条,且雨滴产生在 $(x', y')$,那么当且仅当 $x_1 \le x' \le x_2$ 且 $y \le y'$ 时,雨滴将无法到达地面。由于游戏中存在一个漏洞,新创建的条可以与之前创建的条重叠(为什么?因为是 Ubihard 做的!)。
  • 在每一轮中,破坏者会先添加一个条。然后,造物主会创造 1 个雨滴。

给定破坏者的移动,求你在每一轮中能获得的最大积分。

输入格式

第一行包含两个整数 $n, m$ ($1 \le n, m \le 10^5$),表示框架的右上角 $(n, m)$。第二行包含一个整数 $q$ ($1 \le q \le 10^5$),表示你和你兄弟总共进行的轮数。接下来的 $q$ 行,每行包含 3 个整数 $x_1, x_2, y$ ($0 \le x_1 < x_2 \le n, 0 \le y \le m$),代表你兄弟的一次移动,即创建一个端点为 $(x_1, y)$ 和 $(x_2, y)$ 的条。

输出格式

对于每一轮,输出一行,表示你在该轮中能获得的最大积分。

样例

输入 1

5 5
3
0 2 4
3 5 3
0 5 2

输出 1

5
4
2

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.