QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100

#352. 生存戰略

الإحصائيات

我讨厌「命运」这个词 出生 相遇 离别 成功和失败 人生的幸运和不幸 如果这些都是由命运事先决定好了的话 那我们又是为何而生的呢 在富裕家庭里出生的人 由漂亮妈妈生下来的人 正逢饥荒和战争时期出生的人 如果这一切都是命运 那神明可就太不讲道理 太残酷了 从那时开始 我们就没有未来 因为我们深知 自己必将一事无成
《回转企鹅罐》

給你一個 $n\times m$ 的矩陣,從上往下行數遞增,從左到右列數遞增,對它進行 $q$ 次操作:

  1. 給定 $x_1, y_1, x_2, y_2, v$,將 $x_1\le x\le x_2, y_1\le y\le y_2$ 範圍內的數都加上 $v$。
  2. 給定 $x_1, y_1, l, t$,將左上角為 $(x_1, y_1)$、邊長為 $l+1$ 的正方形區域內的數逆時針旋轉 $t\times 90^\circ$。

有個測試點中存在 $opt=0$ 的情況,請將其視為 $opt=2$ 處理。

請輸出操作結束後的矩陣。

矩陣內的數均對 $2^{32}$ 取模,這意味著你可以使用 unsigned int 進行計算。

輸入格式

第一行輸入四個數 $n, m, q, \mathrm{lim}$。

接下來 $q$ 行,每行第一個數為 $opt$ 表示操作類型,隨後輸入對應操作類型的參數。

輸出格式

為了降低輸出量,請輸出 $\mathrm{lim}$ 個數。

假設矩陣中第 $i$ 行第 $j$ 列的數為 a[i][j],令

output[((i - 1) * m + j - 1) % lim] ^= a[i][j] + ((i - 1) * m + j - 1) / lim

輸出陣列 output[0], output[1], ... output[lim - 1] 即可。

範例

範例 1 輸入

4 4 2 16
1 2 2 4 4 1
2 3 1 1 1

範例 1 輸出

0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1

說明 1

第一次操作:

0 0 0 0
0 1 1 1
0 1 1 1
0 1 1 1

第二次操作:

0 0 0 0
0 1 1 1
1 1 1 1
0 0 1 1

資料範圍

對於 $100\%$ 的資料,保證 $1\le n, m, q\le 2,000, \mathrm{lim} = \min(nm, 10^5)$。

測試點 $n,m$ 特殊性質
$1,2$ $\le100$
$3,4,5,6$ $\le600$
$7,8$ 沒有操作 2
$9$ 所有操作 1 在操作 2 之前
$10$

表格中空白處表示沒有額外限制。

提示

這是一道低級資料結構題。

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.