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 -

Figure 1. Illustration of the grid operations and queries.

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.