Public Judge

pjudge

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#21790. 【NOIP Round #6】倒腾

Statistics

题目描述

给定一个 $n\times m$ 的矩阵,每个位置可能为空也可能写了一个小写字母。

你需要维护 $q$ 次操作,操作分为四种:

  • D:重力方向向下,所有字母都向下落。换句话说,对于每一列,把这一列里的字母按原来的顺序排在最下方。
  • U:重力方向向上,所有字母都向上“落”。
  • L:重力方向向左,所有字母都向左“落”。
  • R:重力方向向右,所有字母都向右“落”。

如果原矩阵为

.a.b.c
aabb..
..ccdd

那么经过操作 L 之后会变成

abc...
aabb..
ccdd..

输出经过 $q$ 次操作之后矩阵的样子。

输入格式

第一行三个正整数 $n,m,q$ 。

第二行一个长度为 $q$ 的字符串,里面只包含 DULR 四种字符。

接下来 $n$ 行,每行一个长度为 $m$ 的字符串,里面只包含小写字母和 . ,表示矩阵的一行。

输出格式

输出 $n$ 行,每行一个长度为 $m$ 的字符串,里面只包含小写字母和 . ,表示最终的矩阵。

样例

样例输入

6 8 5
DLURD
k.l.ndi.
.....c..
......ih
j..a....
..cb....
..c...ef

样例输出

........
........
........
......hf
..iadice
.lkcbnjc

数据范围

对于 $30\%$ 的数据,保证 $1\le n,m,q\le 10$ 。

对于所有数据,保证 $1\le n,m,q\le 100$ 。

Discussions

About Discussions

The discussion section is only for posting: Editorials, 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. Submitting multiple issues may cause your account to be banned.
  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.