#include <iostream>
#include <string>
#include <cstring>
using namespace std; int dir[4][2]={{0,-1},{0,1},{-1,0},{1,0}};
int mat[20][20],tar[20][20],tar2[20][20];
char transtar[20][20];
int pxvalue[16]; int main()
{
int testcase;
cin>>testcase;
for(int s=1;s<=testcase;s++)
{
memset(mat,0,sizeof(mat));
memset(tar,0,sizeof(tar));
memset(pxvalue,0,sizeof(pxvalue));
int day,tmp,tmpx,tmpy;
cin>>day; for(int i=0;i<16;i++)
{
cin>>pxvalue[i];
} for(int i=0;i<20;i++)
{
for(int j=0;j<20;j++)
{
cin>>mat[i][j];
}
} for(int k=0;k<day;k++)
{
for(int i=0;i<20;i++)
{
for(int j=0;j<20;j++)
{
tmp=mat[i][j];
for(int z=0;z<4;z++)
{
tmpx=i+dir[z][0];
tmpy=j+dir[z][1];
if(tmpx>=0 && tmpx<20 && tmpy>=0 && tmpy<20)
tmp+=mat[tmpx][tmpy];
} tar[i][j] = mat[i][j]+pxvalue[tmp]; if(tar[i][j]>3)
tar[i][j]=3;
if(tar[i][j]<0)
tar[i][j]=0;
}
}
memcpy(mat,tar,sizeof(mat)); //滚动更新,重中之重
} for(int i=0;i<20;i++)
{
for(int j=0;j<20;j++)
{
if(tar[i][j]==0)
{
transtar[i][j]='.';
}
else if(tar[i][j]==1)
{
transtar[i][j]='!';
}
else if(tar[i][j]==2)
{
transtar[i][j]='X';
}
else if(tar[i][j]==3)
transtar[i][j]='#';
}
} for(int i=0;i<20;i++)
{
for(int j=0;j<20;j++)
{
cout<<transtar[i][j];
}
cout<<endl;
}
if(s!=testcase)
cout<<endl; }
return 0;
}

hdu1057的更多相关文章

  1. ACM训练计划建议(写给本校acmer,欢迎围观和指正)

    ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...

  2. ACM训练计划建议(转)

    ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...

随机推荐

  1. tomcat7 中的坑。 关于welcome-list和servlet-mapping

    web.xml中, 使用default servlet设置了针对静态资源后缀名的过滤. 并且设置了welcome-list, 使用jetty和tomcat6启动一切正常, 但是使用tomcat7则出现 ...

  2. Java -- Properties类使用 读取配置文档

    Java-Properties类的使用 分类: Java基础 2007-05-11 19:35 2666人阅读 评论(1) 收藏 举报 propertiesxmlimportexceptionstri ...

  3. Selenium-几种元素定位方式

    #识别元素并操作#一般有如下几种方法,其中id最为常用.这里需要注意识别元素一定要用唯一id 1.find_element_by_id("value") #! /usr/bin/e ...

  4. kylin_学习_01_kylin安装部署

    一.环境准备 根据官方文档,kylin是需要运行在hadoop环境下的,如下图: 1.hadoop环境搭建 参考:hadoop_学习_02_Hadoop环境搭建(单机) 2.hbase环境搭建 参考: ...

  5. QTableWidget设计原则

    一.组成结构: 列表控件由水平表头(self.horizontalHeader()).垂直表头(self.verticalHeader())和单元格(QTableWidgetItem)组成 其中表头又 ...

  6. python中类__call__方法与@classmethod

    实现了__call__方法的类就变成了一个可调用对象,可以像函数一样调用,callable(obj)就返回True,否则返回False. 参考:https://www.cnblogs.com/supe ...

  7. NOI 模拟赛 #2

    得分非常惨惨,半个小时写的纯暴力 70 分竟然拿了 rank 1... 如果 OYJason 和 wxjor 在可能会被爆踩吧 嘤 T1 欧拉子图 给一个无向图,如果一个边集的导出子图是一个欧拉回路, ...

  8. [Codeforces 204E] Little Elephant and Strings

    [题目链接] https://codeforces.com/contest/204/problem/E [算法] 首先构建广义后缀自动机 对于自动机上的每个节点 , 维护一棵平衡树存储所有它所匹配的字 ...

  9. 【LeetCode】024. Swap Nodes in Pairs

    Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2-&g ...

  10. H5 限制input只能输入数字

    <input type="tel" /> 参考: http://blog.csdn.net/kongjiea/article/details/40185951