hdu1057
#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的更多相关文章
- ACM训练计划建议(写给本校acmer,欢迎围观和指正)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
- ACM训练计划建议(转)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
随机推荐
- 如何阻止form表单中的button按钮提交
<form action="#" method="post"> <input type="text" name=" ...
- Ansible Ad-Hoc命令集
Ad-Hoc Ad-Hoc就是 “临时命令”, 从功能上讲 Ad-Hoc跟Ansible-playbook都差不多,Ansible提供了两种完成任务的方式: Ad-Hoc命令集与Ansible-pla ...
- codeforces 655B B. Mischievous Mess Makers(贪心)
题目链接: B. Mischievous Mess Makers time limit per test 1 second memory limit per test 256 megabytes in ...
- 第十七章-异步IO
异步IO的出现源自于CPU速度与IO速度完全不匹配 一般的可以采用多线程或者多进程的方式来解决IO等待的问题 同样异步IO也可以解决同步IO所带来的问题 常见的异步IO的实现方式是使用一个消息循环, ...
- stl_heap.h
stl_heap.h // Filename: stl_heap.h // Comment By: 凝霜 // E-mail: mdl2009@vip.qq.com // Blog: http://b ...
- 【遍历二叉树】11把二叉树转换成前序遍历的链表【Flatten Binary Tree to Linked List】
本质上是二叉树的root->right->left遍历. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- CI中控制器名不能和本个 控制器中的方法名相同
控制器名称:application/controllers/tang.php 控制器中方法名称:application/controllers/role.php 中有方法 public funct ...
- 1068 Find More Coins (30)(30 分)
Eva loves to collect coins from all over the universe, including some other planets like Mars. One d ...
- 洛谷【P1358】扑克牌
我对状态空间的理解:https://www.cnblogs.com/AKMer/p/9622590.html 题目传送门:https://www.luogu.org/problemnew/show/P ...
- LCS(最长公共子序列问题)
LCS(Longest Common Subsequence),即最长公共子序列.一个序列,如果是两个或多个已知序列的子序列,且是所有子序列中最长的,则为最长公共子序列. 原理: 事实上,最长公 ...