QOJ.ac

QOJ

حد الوقت: 10 s حد الذاكرة: 512 MB مجموع النقاط: 100 الصعوبة: [عرض]

#967. 矩形涂色

الإحصائيات

存在一个在左、右和上方无限延伸的网格(所有坐标为 $(x, y)$ 且 $x \in \mathbb{Z}, y \ge 0$ 的单元格均存在)。初始时,所有单元格均为白色。你需要处理 $q$ 个两种类型的查询:

  1. $y_i \ l_i \ r_i$:将所有满足 $l_i \le x \le r_i$ 的单元格 $(x, y_i)$ 涂成黑色。如果单元格已经是黑色,其颜色保持不变。
  2. $l_i \ r_i$:考虑所有 $x$ 坐标在区间 $[l_i, r_i]$ 内的单元格。找到最高的单元格,使得其正下方的所有单元格均为黑色。形式化地,你需要找到最大的 $h$,使得 $\exists x \in [l_i, r_i] \forall y \in [0, h)$,单元格 $(x, y)$ 为黑色。

为了强制在线处理查询,查询经过了先前答案的加密。

输入格式

第一行包含一个整数 $q$ ($1 \le q \le 10^5$),表示要处理的查询数量。 接下来的 $q$ 行包含加密后的查询描述。设 $S$ 为目前为止已处理的所有第二类查询的答案之和。 每个描述的格式为 “$1 \ (y_i \oplus S) \ (l_i \oplus S) \ (r_i \oplus S)$” 或 “$2 \ (l_i \oplus S) \ (r_i \oplus S)$”。保证解密后的参数满足 $0 \le y_i \le 2 \cdot 10^5$,$0 \le l_i \le r_i \le 2 \cdot 10^5$。注意,保证是针对解密后的参数给出的,输入中的数字可能无法用 32 位整数表示。 在每次第二类查询后,别忘了将新的答案加到 $S$ 中。

输出格式

按顺序输出所有第二类查询的答案,每行一个。

样例

输入格式 1

10
1 0 1 1
2 0 10
1 1 9 9
1 0 0 6
1 0 3 9
2 5 5
1 1 5 5
2 5 5
2 0 5
1 7 6 3

输出格式 1

1
0
2
2

说明

本题的查询处理过程如下表所示:

$S$ 加密后的查询 解密后的查询 答案
0 1 0 1 1 1 0 1 1
0 2 0 10 2 0 10 1
1 1 1 9 9 1 0 8 8
1 1 0 0 6 1 1 1 7
1 1 0 3 9 1 1 2 8
1 2 5 5 2 4 4 0
1 1 1 5 5 1 0 4 4
1 2 5 5 2 4 4 2
3 2 0 5 2 3 6 2
5 1 7 6 3 1 2 3 6

图 1. 网格操作与查询的可视化。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1557EditorialOpenNew Editorial for Problem #967xcx09022026-04-16 19:37:17View
#590Editorial Open集训队作业 解题报告 by 孙梓航Qingyu2026-01-02 22:40:44 Download

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.