当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2898:Entertainment

题目描述
ACM-ICPC judges, sometimes, play computer games, such as Alphariz. In the game of Alphariz, you are given a table (e.g., Table I) of alphabetic characters. At each step of the game, you choose a table entry E containing a non-blank character ch. Then, you recursively identify all the friends of E. The friends are the existing table entries containing the same character ch which are located immediately to the left, right, up, and down directions of E, and their friends in turn, until no new friends can be located. Then, you replace the characters in E and its found friends with blanks. Table II shows the result of applying the latter rule on Table I, starting at entry E in row 1 and column 2, where ch is 'a'.

Then, while still in the same step, you shift all the non-blank characters to the left and the blanks to the right, as is shown in Table III. Next, you shift all non-blank characters down and the blanks are shifted up as is shown in Table IV. Note that possible full blank rows or columns are to be deleted.

You are to write a program that given the initial table and a sequence of selected table entries, apply the above rules for each given table entry, one after another, and report the final resulting table.
输入解释
The input consists of several test cases. Each test case starts with the character map which is given in m lines of length n characters (1 <= m, n <= 1000). Characters in the initial map are all lowercase letters. After this, there is a single line containing a single integer k which is the number of selected table entries, followed by k lines, containing two integers r (1 <= r <= m) and c (1 <= c <= n) which are the row and the column numbers of the table entry, respectively. Besides, the items are always inside the current table.
输出解释
The output for the ith test case should start with a line in the following format:
Test case #i:
After the first line, the final map should be written with the same format as in the input.
输入样例
aabbb
abaab
aaaba
abbaa
1
1 2
aba
bbc
2
1 3
2 2
输出样例
Test case #1:
bb
bb
bab
bbaa
Test case #2:
a
c

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Tehran 2005

源链接: POJ-2898

最后修改于 2020-10-29T06:46:59+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536