-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10443_Rock.cpp
51 lines (47 loc) · 1.17 KB
/
10443_Rock.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
unordered_map<char,char> weak = {{'S','R'},{'R','P'},{'P','S'}};
using vc = vector<char>;
using vvc = vector<vc>;
char war(vvc &m, int r, int c){
char s = weak[m[r][c]];
if(r > 0 && m[r-1][c] == s) return s;
if(r < m.size()-1 && m[r+1][c] == s) return s;
if(c > 0 && m[r][c-1] == s) return s;
if(c < m[r].size()-1 && m[r][c+1] == s) return s;
return m[r][c];
}
int main()
{
int test;
cin >> test;
while(test--){
int r, c , d;
cin >> r >> c >> d;
vvc v(r,vc(c));
for(int i = 0; i < r; i++){
for(int j = 0; j < c; j++){
cin >> v[i][j];
}
}
while(d--){
vvc temp(r,vc(c,0));
for(int i = 0; i < r; i++){
for(int j = 0; j < c; j++){
temp[i][j] = war(v,i,j);
}
}
v = temp;
}
for(int i = 0; i < r; i++){
for(int j = 0; j < c; j++){
cout << v[i][j];
}
cout << endl;
}
if(test) cout << endl;
}
return 0;
}