QOJ.ac

QOJ

実行時間制限: 10 s メモリ制限: 512 MB 満点: 100 難易度: [表示]

#967. 長方形の塗りつぶし

統計

左右および上方向に無限に広がるセルグリッドが存在する($x \in \mathbb{Z}, y \ge 0$ を満たすすべてのセルが存在する)。初期状態ではすべてのセルは白である。以下の2種類のクエリを $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]$ にあるすべてのセルを考える。その直下のすべてのセルが黒であるような、最も高いセルを見つける。厳密には、$\exists x \in [l_i, r_i] \forall y \in [0, h)$ でセル $(x, y)$ が黒であるような最大の $h$ を求める。

クエリをオンラインで処理するために、クエリは過去の回答を用いて暗号化されている。

入力

最初の行には、処理するクエリの数 $q$ ($1 \le q \le 10^5$) が含まれる。 続く $q$ 行には、暗号化されたクエリの記述が含まれる。これまでに処理された2種類目のクエリの回答の合計を $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ビット整数に収まらない可能性がある。

2種類目のクエリの回答を得るたびに、その値を $S$ に加算することを忘れないこと。

出力

2種類目のクエリに対する回答を、それぞれ別の行に出力せよ。

入出力例

入力 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.