QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓

#17946. 초콜릿 종류 맞히기

통계

猜巧克力种类游戏按如下方式进行:

首先,准备一个大小为 $N \times N$ 的正方形模具和几种不同种类的巧克力,并在模具的每个格子中放入一块巧克力。巧克力的种类可以用一个大写英文字母表示。

然后,在纸上提前写下如何移动巧克力模具。移动模具的方法有:顺时针旋转 $90$ 度(R)、逆时针旋转 $90$ 度(L)、水平翻转(H)、垂直翻转(V)。这些操作的序列可以用一个长度为 $M$ 的字符串 $S$ 表示。

准备好这两样东西后,一个人喊出两个整数 $r$ 和 $c$。另一个人需要猜出在按照 $S$ 移动巧克力模具后的结果中,位于第 $r$ 行第 $c$ 列的巧克力种类。

(todo: 待添加带有图示的样例说明)

Coco 在这个游戏中制作了一个可以代替 Coco 猜巧克力种类的机器人。作为对手,Hanbyul 制作了一个可以将 $S$ 中从第 $l$ 个到第 $r$ 个操作全部修改为操作 $x$ 的机器人。为了让 Coco 的机器人能够战胜 Hanbyul 的机器人,请编写一个新程序。

输入格式

第一行包含一个整数 $N$。$(1 \le N \le 1\,000)$

接下来的 $N$ 行,每行包含 $N$ 个大写英文字母,表示巧克力模具的初始状态,字母之间没有空格。

下一行包含一个整数 $M$。$(1 \le M \le 500\,000)$

下一行包含一个长度为 $M$ 的字符串 $S$,表示移动巧克力模具的操作序列。$S$ 仅由 RLHV 组成。

下一行包含一个整数 $Q$,表示查询的数量。$(1 \le Q \le 500\,000)$

接下来的 $Q$ 行,每行包含一个查询。查询的格式如下:

  • 1 r c:输出按照当前的 $S$ 移动巧克力模具后,第 $r$ 行第 $c$ 列的巧克力种类,占一行。$(1 \le r, c \le N)$
  • 2 l r x:设 $S$ 的第 $i$ 个操作为 $S_i$,对于所有满足 $l \le i \le r$ 的整数 $i$,将 $S_i$ 修改为 $x$。$(1 \le l \le r \le M;$ $x$ 是 RLHV 中的一个$)$

保证 1 号查询至少出现一次。

输出格式

对于每个 1 号查询,输出对应的答案,每个答案占一行。

样例

输入样例 1

3
ABC
DEF
GHI
4
RHLV
4
1 1 1
2 3 4 R
2 2 3 L
1 3 3

输出样例 1

A
I

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.