A purely simulated problem.
1#include <cstdio>2#include <cstring>3#include <cstdlib>4 5 #defineMAXN 206 #defineMAXM 167 8 CharTb[] =".! x#";9 intD[MAXM];Ten intmap[2][maxn+2][maxn+1]; One intdir[4][2] = { A{-1,0}, {1,0}, {0,1}, {0,-1} - }; - the intIsinvalid (intXinty) { - returnx<0|| X>=MAXN | | y<0|| y>=MAXN; - } - + intMain () { - intt, N; + intI, J, K, p, R; A intx, y; at intsum; - - #ifndef Online_judge -Freopen ("data.in","R", stdin); -Freopen ("Data.out","W", stdout); - #endif inmemset (Map,0,sizeof(map)); -scanf"%d", &t); to while(t--) { +scanf"%d", &n); - for(i=0; i<maxm; ++i) thescanf"%d", &d[i]); * for(r=0, i=1; i<=maxn; ++i) { $ for(j=1; j<=maxn; ++j) {Panax Notoginsengscanf"%d", &map[r][i][j]); - } the } + for(p=0; p<n; ++p, r=!r) { A for(i=1; i<=maxn; ++i) { the for(j=1; j<=maxn; ++j) { +sum = map[r][i][j] + map[r][i+1][J] + map[r][i-1][j]+ -map[r][i][j+1] + map[r][i][j-1]; $MAP[!R][I][J] = Map[r][i][j] +D[sum]; $ if(Map[!r][i][j] >3) -MAP[!R][I][J] =3; - if(Map[!r][i][j] <0) theMAP[!R][I][J] =0; - }Wuyi } the } - for(i=1; i<=maxn; ++i) { Wu for(j=1; j<=maxn; ++j) { -printf"%c", Tb[map[r][i][j]]); About } $printf"\ n"); - } - if(t) -printf"\ n"); A } + the return 0; -}
"Hdoj" 1057 A New growth industry