HDU1057

View Code
 1 /*
 2 模拟 简单
 3 res[i][j]=mat[i][j]+d[sum];
 4 其中sum=mat[i][j]+i,j其他四个方向的值
 5 */
 6 #include<stdio.h>
 7 #include<string.h>
 8 #include<stdlib.h>
 9 #include<algorithm>
10 #include<iostream>
11 #include<queue>
12 //#include<map>
13 #include<math.h>
14 using namespace std;
15 typedef long long ll;
16 //typedef __int64 int64;
17 const int maxn = 25;
18 const int inf = 0x7fffffff;
19 const int pi=acos(-1.0);
20 int mat[ maxn ][ maxn ],res[ maxn ][ maxn ];
21 int d[ maxn ];
22 const int dx[]={0,0,-1,1};
23 const int dy[]={1,-1,0,0};
24 
25 void solve(){
26     for( int i=1;i<=20;i++ ){
27         for( int j=1;j<=20;j++ ){
28             int x,y,sum=0;
29             sum=mat[ i ][ j ];
30             for( int k=0;k<4;k++){
31                 x=i+dx[ k ];
32                 y=j+dy[ k ];
33                 if( x<1||x>20||y<1||y>20)continue;
34                 sum+=mat[ x ][ y ];
35             }
36             res[ i ][ j ]=d[ sum ]+mat[ i ][ j ];
37             if( res[ i ][ j ]<0 ) res[ i ][ j ]=0;
38             else if( res[ i ][ j ]>3 ) res[ i ][ j ]=3;
39         }
40     }
41     return ;
42 }
43 
44 int main(){
45     int ca;
46     scanf("%d",&ca);
47     for(int c=1;c<=ca;c++){
48     if(c!=1)printf("\n");
49     int n;
50     scanf("%d",&n);
51         memset( mat,0,sizeof(mat) );
52         memset( res,0,sizeof(res) );
53         for( int i=0;i<16;i++ ) scanf("%d",&d[ i ]);
54         for( int i=1;i<=20;i++ )
55             for( int j=1;j<=20;j++ )
56                 scanf("%d",&mat[ i ][ j ]);
57         for( int t=1;t<=n;t++ ){
58             solve();
59             memcpy( mat,res,sizeof(res) );
60         }
61         for( int i=1;i<=20;i++ ){
62             for( int j=1;j<=20;j++ ){
63                 if( res[ i ][ j ]==0 ) printf(".");
64                 else if( res[ i ][ j ]==1 ) printf("!");
65                 else if( res[ i ][ j ]==2 ) printf("X");
66                 else if( res[ i ][ j ]==3 ) printf("#");
67             }
68             printf("\n");
69         }
70     }
71     return 0;
72 }

 

转载于:https://www.cnblogs.com/xxx0624/archive/2012/12/11/2812778.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值