UVa 10443
From Algorithmist
Contents |
[edit] 10443 - Rock, Scissors, Paper
http://acm.uva.es/p/v104/10443.html
[edit] Summary
We have a R x C matrix of 'R's 'S's and 'P's ( rock, scissors and paper, respectively ). Like the known game of same name, 'R' beat 'S' that beat 'P' that beat 'R'.
Every day, each R|S|P try to get your vertical/horizontal adjacent position.
your mission is to show the state of the matrix before the Nth day.
[edit] Explanation
The positions will only be changed at the end of day. Cause it, you may keep 2 matrix, one for today, and one for tomorrow.
[edit] Gotchas
One 'R' only can be changed for 'P'. and, iff 'R' have a 'P' as neighbor. One 'S' only can be changed for 'R'. and, iff 'S' have a 'R' as neighbor. One 'P' only can be changed for 'S'. and, iff 'P' have a 'S' as neighbor.
[edit] Example
|RSPR| |RRSP| |RRRS| |RRRR| |SPRS| == 1st day ==> |RSPR| == 2nd day ==> |RRSP| == 3rd day ==> |RRRS| . . . |PRSP| |SPRS| |RSPR| |RRSP|
[edit] Input
2 3 3 1 RRR RSR RRR 3 4 2 RSPR SPRS PRSP 10 10 10 SSSSSRRRRR PPPPPPPPPP PSPSPSPSPS PRPRPRPRPR RPRPRPRPRP PPPPPRRRRR SSSSSRRRRR RRSPRRSPRR PPPSSSSSSS SSSSSSSSSS
[edit] Output
RRR RRR RRR RRRS RRSP RSPR SSRPPSPSPS SRSRPRSRSR RPRPRPRPRP SSSSSSSPSP SSSSRSSPPP SRSRPRSSPR RPRPSSSSSP PSPRSSPRSS SSRPSPRPSP PSSRPRSRPR

