QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#18458. Flowerbed Redecoration

Statistiques

Joon-Pyo 在他家门前装饰了一个花坛。花坛呈 $n \times m$ 的网格形状,每个格子中都种植着一朵花。花共有 26 种颜色,分别对应从 A 到 Z 的 26 个大写字母。突然,他想重新装饰这个花坛。

花坛太大了,无法逐一调整花朵。他租用了一些设备,可以提起并旋转一块边长为 $d$ 的正方形土地。他计划按照以下顺序进行施工,以期花坛能够得到妥善的重新装饰。

  1. 放置设备,使其恰好覆盖前 $d$ 行和前 $d$ 列的花朵。
  2. 将设备内的 $d \times d$ 正方形区域顺时针旋转 $90^\circ$。如果该正方形包含最后 $d$ 行和最后 $d$ 列的花朵,则施工结束。否则,如果该正方形不包含最后 $d$ 列的花朵,将设备向右移动 $x$ 个单位。否则,将设备向下移动 $y$ 个单位,并移动到最左侧,使其包含前 $d$ 列的花朵。
  3. 重复步骤 2,直到施工结束。

请注意,由于 $x$、$y$ 和 $d$ 在施工开始前已经过仔细确定,设备永远不会移出花坛。

在不知道最终结果的情况下,他无法开始施工。请编写一个程序输出最终的结果。

输入格式

第一行给出五个整数 $n, m, y, x$ 和 $d$($1 \le n \times m \le 10^6$,$1 \le y \le n$,$1 \le x \le m$,$1 \le d \le \min(n, m)$,$n \equiv d \pmod y$,$m \equiv d \pmod x$)。

接下来的 $n$ 行,每行包含恰好 $m$ 个大写字母,表示当前的花坛。

输出格式

输出 $n$ 行,每行包含 $m$ 个大写字母,表示计划施工完成后的花坛。

样例

输入样例 1

4 4 1 1 2
AAAA
BBBB
AAAA
BBBB

输出样例 1

BAAA
ABBB
BAAA
BBBA

输入样例 2

6 5 1 2 3
RBRCY
YBPBR
PBRCY
CYPBR
PBRCY
CYPBR

输出样例 2

PYRBR
CRCBB
PPBPY
CRCYB
YRBCY
PYRBR

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.