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

建议使用的浏览器:

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

2339:Rock, Scissors, Paper

题目描述
Bart's sister Lisa has created a new civilization on a two-dimensional grid. At the outset each grid location may be occupied by one of three life forms: Rocks, Scissors, or Papers. Each day, differing life forms occupying horizontally or vertically adjacent grid locations wage war. In each war, Rocks always defeat Scissors, Scissors always defeat Papers, and Papers always defeat Rocks. At the end of the day, the victor expands its territory to include the loser's grid position. The loser vacates the position.
Your job is to determine the territory occupied by each life form after n days.
输入解释
The first line of input contains t, the number of test cases. Each test case begins with three integers not greater than 100: r and c, the number of rows and columns in the grid, and n. The grid is represented by the r lines that follow, each with c characters. Each character in the grid is R, S, or P, indicating that it is occupied by Rocks, Scissors, or Papers respectively.
输出解释
For each test case, print the grid as it appears at the end of the nth day. Leave an empty line between the output for successive test cases.
输入样例
2
3 3 1
RRR
RSR
RRR
3 4 2
RSPR
SPRS
PRSP
输出样例
RRR
RRR
RRR

RRRS
RRSP
RSPR

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

源链接: POJ-2339

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

共提交 0

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