Rock, Scissors, Paper


Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type
Allowed languages
Java 19, Java 8

題目說明

在一個 r × c 的二維地圖上,每一格住著一種生命體:

  • R:Rock,石頭
  • S:Scissors,剪刀
  • P:Paper,布

每天,相鄰的生命體會互相戰鬥。只有上下左右四個方向算相鄰,斜角不算。

勝負規則如下:

Rock     打敗 Scissors
Scissors 打敗 Paper
Paper    打敗 Rock

如果某個格子與鄰近格子中的生物發生戰鬥而失敗,則在當天結束時,該格子會被勝利者佔領。 註:一天只會戰鬥一次

輸入值的格式

第一行包含三個整數:r,c,n

r:地圖列數

c:地圖行數

n:模擬天數

接下來有 r 行,每行包含 c 個字元,表示初始地圖。

輸出值的格式

輸出模擬n天後的地圖。

sample input1

3 3 1
RRR
RSR
RRR

sample output1

RRR
RRR
RRR

說明:中央的 S 被四周的 R 包圍,而 R 可以打敗 S,因此經過一天後中央位置變成 R

sample input2

3 4 2
RSPR
SPRS
PRSP

sample output2

RRRS
RRSP
RSPR

Comments

There are no comments at the moment.