forked from marioyc/Online-Judge-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1051 - A New Growth Industry.cpp
executable file
·53 lines (42 loc) · 1.5 KB
/
1051 - A New Growth Industry.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
52
53
#include<iostream>
using namespace std;
int main(){
int T,days,K,I,J;
int D[16];
int M[2][20][20];
int di[]={0,0,0,1,-1};
int dj[]={0,1,-1,0,0};
scanf("%d",&T);
for(int caso=0;caso<T;caso++){
scanf("%d",&days);
for(int i=0;i<16;i++) scanf("%d",&D[i]);
for(int i=0;i<20;i++)
for(int j=0;j<20;j++) scanf("%d",&M[0][i][j]);
for(int k=1;k<=days;k++){
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
K=0;
for(int a=0;a<5;a++){
I=i+di[a];
J=j+dj[a];
if(I>=0 && I<20 && J>=0 && J<20) K+=M[(k-1)%2][I][J];
}
M[k%2][i][j]=M[(k-1)%2][i][j]+D[K];
if(M[k%2][i][j]>3) M[k%2][i][j]=3;
else if(M[k%2][i][j]<0) M[k%2][i][j]=0;
}
}
}
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(M[days%2][i][j]==0) printf(".");
else if(M[days%2][i][j]==1) printf("!");
else if(M[days%2][i][j]==2) printf("X");
else if(M[days%2][i][j]==3) printf("#");
}
printf("\n");
}
if(caso!=T-1) printf("\n");
}
return 0;
}