QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 2048 MB Total points: 100

#5728. 计算机缓存

Statistics

你的计算机拥有一个包含 $n$ 个不同地址的缓存,索引从 $1$ 到 $n$。每个地址可以存储一个字节。第 $i$ 个字节记为 $a_i$。最初,所有缓存字节的值均为零。形式上,缓存可以建模为一个长度为 $n$ 的字节数组,初始时全为零。

你有 $m$ 个不同的数据块需要存储。第 $i$ 个数据块是一个长度为 $s_i$ 的字节数组 $x_i$。

你将对计算机执行 $q$ 次不同的操作。操作共有三种类型:

1 $i$ $p$:将数据 $i$ 从缓存的第 $p$ 个位置开始加载。形式上,这意味着设置 $a_p = x_{i,1}, a_{p+1} = x_{i,2}, \dots, a_{p+s_i-1} = x_{i,s_i}$,其中 $x_{i,k}$ 表示数组 $x_i$ 的第 $k$ 个字节。这会覆盖缓存中之前存储的任何值。保证这是一个有效操作(例如 $s_i + p - 1 \le n$)。同一数据的多个版本可能同时被加载到多个位置。

2 $p$:打印存储在地址 $p$ 处的字节。

3 $i$ $l$ $r$:将第 $i$ 个数据块中第 $l$ 到第 $r$ 个字节的值加 $1$,模 $256$。形式上,这意味着对于 $l \le k \le r$,设置 $x_{i,k} = (x_{i,k} + 1) \pmod{256}$。这不会影响已经加载到缓存中的值,仅影响未来的加载操作。

输入格式

第一行包含三个数字 $n, m$ 和 $q$。

接下来的 $m$ 行包含数据描述,每行一个。接下来的 $q$ 行包含操作描述,每行一个。

保证输入中至少包含一个类型为 2 的打印查询操作。此外:

$1 \le n, m, q \le 5 \times 10^5$ $\sum_i s_i \le 5 \times 10^5$ $s_i \ge 1$ $0 \le x_{i,j} \le 255$

输出格式

你的程序必须为每个类型为 2 的操作输出结果,每行一个整数值。

说明

样例解释:

2 1:缓存中尚未放入任何内容,因此打印 0 1 2 2:缓存变为 [0, 1, 2, 1, 3] 1 1 1:缓存变为 [255, 0, 15, 1, 3] 2 1:打印缓存的第一个值,即 255 2 4:打印缓存的第四个值,即 1 3 1 1 2:第一个数据块变为 [0, 1, 15]。缓存仍为 [255, 0, 15, 1, 3] 2 1:打印缓存的第一个值,即 255 1 1 2:缓存变为 [255, 0, 1, 15, 3] 2 2:打印缓存的第二个值,即 0 2 5:打印缓存的第五个值,即 3

样例

输入 1

5 2 10
3 255 0 15
4 1 2 1 3
2 1
1 2 2
1 1 1
2 1
2 4
3 1 1 2
2 1
1 1 2
2 2
2 5

输出 1

0
255
1
255
0
3

Figure 1. Cache representation

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.