• 【HDOJ】1057 A New Growth Industry


    纯粹的模拟题目。

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <cstdlib>
     4 
     5 #define MAXN 20
     6 #define MAXM 16
     7 
     8 char tb[] = ".!X#";
     9 int D[MAXM];
    10 int map[2][MAXN+2][MAXN+1];
    11 int dir[4][2] = {
    12     {-1,0}, {1,0}, {0,1}, {0,-1}
    13 };
    14 
    15 int isInvalid(int x, int y) {
    16     return x<0 || x>=MAXN || y<0 || y>=MAXN;
    17 }
    18 
    19 int main() {
    20     int t, n;
    21     int i, j, k, p, r;
    22     int x, y;
    23     int sum;
    24 
    25 #ifndef ONLINE_JUDGE
    26     freopen("data.in", "r", stdin);
    27     freopen("data.out", "w", stdout);
    28 #endif
    29     memset(map , 0, sizeof(map));
    30     scanf("%d", &t);
    31     while (t--) {
    32         scanf("%d", &n);
    33         for (i=0; i<MAXM; ++i)
    34             scanf("%d", &D[i]);
    35         for (r=0, i=1; i<=MAXN; ++i) {
    36             for (j=1; j<=MAXN; ++j) {
    37                 scanf("%d", &map[r][i][j]);
    38             }
    39         }
    40         for (p=0; p<n; ++p, r=!r) {
    41             for (i=1; i<=MAXN; ++i) {
    42                 for (j=1; j<=MAXN; ++j) {
    43                     sum = map[r][i][j] + map[r][i+1][j] + map[r][i-1][j]+
    44                             map[r][i][j+1] + map[r][i][j-1];
    45                     map[!r][i][j] = map[r][i][j] + D[sum];
    46                     if (map[!r][i][j] > 3)
    47                         map[!r][i][j] = 3;
    48                     if (map[!r][i][j] < 0)
    49                         map[!r][i][j] = 0;
    50                 }
    51             }
    52         }
    53         for (i=1; i<=MAXN; ++i) {
    54             for (j=1; j<=MAXN; ++j) {
    55                 printf("%c", tb[map[r][i][j]]);
    56             }
    57             printf("
    ");
    58         }
    59         if (t)
    60             printf("
    ");
    61     }
    62 
    63     return 0;
    64 }
  • 相关阅读:
    log4net GetLogger(source).IsInfoEnabled = false
    nginx配置
    mysql数据库备份
    按序号批量更新某个字段
    MySql 执行 DELETE/UPDATE时,报 Error Code: 1175错误
    ef学习记录
    vue-cli3实行路径联想
    GitHub分支创建及合并
    Git本地分支和远程分支关联
    uniapp(三)
  • 原文地址:https://www.cnblogs.com/bombe1013/p/4160668.html
Copyright © 2020-2023  润新知