ZOJ Problem Set - 3804 YY's Minions
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5336
比较简单的模拟题,题意也很好理解。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue> #define CL(arr, val) memset(arr, val, sizeof(arr)) #define ll long long
#define inf 0x7f7f7f7f
#define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0) #define L(x) (x) << 1
#define R(x) (x) << 1 | 1
#define MID(l, r) (l + r) >> 1
#define Min(x, y) (x) < (y) ? (x) : (y)
#define Max(x, y) (x) < (y) ? (y) : (x)
#define E(x) (1 << (x))
#define iabs(x) (x) < 0 ? -(x) : (x)
#define OUT(x) printf("%I64d\n", x)
#define lowbit(x) (x)&(-x)
#define Read() freopen("a.txt", "r", stdin)
#define Write() freopen("b.txt", "w", stdout);
#define maxn 1000000000
#define N 55
using namespace std; int n,m,f,k;
char A[N][N],B[N][N];
int dir[][]={{-,},{-,},{-,-},{,},{,-},{,},{,},{,-}};
struct point
{
int x,y,t;
bool operator < (const point &a) const
{
return t<a.t;
}
}p[N*N]; void solve()
{
for(int i=;i<n;i++)
{
for(int j=;j<m;j++)
{
B[i][j]=A[i][j];
int ans=;
for(int k=;k<;k++)
{
int x=i+dir[k][];
int y=j+dir[k][];
if(x<||x>=n||y<||y>=m) continue;
if(A[x][y]=='') ans++;
}
if(A[i][j]=='')
{
if(ans<) B[i][j]='';
else if(ans>) B[i][j]='';
else B[i][j]='';
}
else if(A[i][j]=='')
{
if(ans==) B[i][j]='';
}
}
}
for(int i=;i<n;i++)
for(int j=;j<m;j++)
A[i][j]=B[i][j];
}
int main()
{
//Read();
//Write()
int q;
scanf("%d",&q);
while(q--)
{
scanf("%d%d%d%d",&n,&m,&f,&k);
getchar();
for(int i=;i<n;i++) scanf("%s",A[i]);
for(int i=;i<k;i++)
{
scanf("%d%d%d",&p[i].t,&p[i].x,&p[i].y);
p[i].x--;
p[i].y--;
}
sort(p,p+k);
for(int i=,j=;i<=f;i++)
{
solve();
while(p[j].t==i)
{
A[p[j].x][p[j].y]='X';
j++;
}
}
for(int i=;i<n;i++)
printf("%s\n",A[i]);
}
return ;
}
ZOJ Problem Set - 3804 YY's Minions的更多相关文章
- ZOJ 3804 YY's Minions (简单模拟)
/* 题意:一个矩阵中有 n*m个宠物,每一个宠物都有一个状态, 1醒着的,0睡着的 X离开的!如果这个宠物(醒着的)的周围醒着的个数>3 || <2它就会睡着, 如果这个宠物(睡着的)的 ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1025解题报告
ZOJ Problem Set - 1025 题目分类:基础题 原题地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=10 ...
- ZOJ Problem Set - 3829Known Notation(贪心)
ZOJ Problem Set - 3829Known Notation(贪心) 题目链接 题目大意:给你一个后缀表达式(仅仅有数字和符号),可是这个后缀表达式的空格不幸丢失,如今给你一个这种后缀表达 ...
- ZOJ Problem Set - 2563 Long Dominoes 【如压力dp】
称号:ZOJ Problem Set - 2563 Long Dominoes 题意:给出1*3的小矩形.求覆盖m*n的矩阵的最多的不同的方法数? 分析:有一道题目是1 * 2的.比較火.链接:这里 ...
- ZOJ Problem Set - 3593 拓展欧几里得 数学
ZOJ Problem Set - 3593 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3593 One Person ...
- ZOJ Problem Set - 2297 Survival 【状压dp】
题目:ZOJ Problem Set - 2297 Survival 题意:给出一些怪,有两个值,打他花费的血和能够添加的血,然后有一个boss,必须把小怪全部都打死之后才干打boss,血量小于0会死 ...
- ZOJ Problem Set - 3820 Building Fire Stations 【树的直径 + 操作 】
题目:problemId=5374" target="_blank">ZOJ Problem Set - 3820 Building Fire Stations 题 ...
- ZOJ Problem Set - 3229 Shoot the Bullet 【有上下界网络流+流量输出】
题目:problemId=3442" target="_blank">ZOJ Problem Set - 3229 Shoot the Bullet 分类:有源有汇 ...
随机推荐
- 【BZOJ】【1001】 【BJOI2006】狼抓兔子
平面图最小割->对偶图最短路 平面图最小割转对偶图最短路= = 想到了就比较好写了…… 可能是我对区域的标号方式比较奇特?反正我没有特判n==1||m==1也能过2333(机智吧-(滚开啦你个自 ...
- HBAO
nv算是坑死我了,之前下的hbao的sample这次怎么都找不到 http://developer.download.nvidia.com/SDK/10.5/direct3d/samples.html ...
- wrap device
刚刚看见了,wrap device && reference device 区别在这里 https://msdn.microsoft.com/en-us/library/windows ...
- 虚拟目录里面的webconfig不继承网站的设置
必須在上一层虚拟目录(如根目录,上级网站)所在的Web.config加上 如:<location path="." allowOverride="false&quo ...
- Nodejs Express 4.X 中文API 2--- Request篇
相关阅读: Express 4.X API 翻译[一] -- Application篇 Express4.XApi 翻译[二] -- Request篇 Express4.XApi 翻译[三] -- ...
- .NET设计模式(14):代理模式(Proxy Pattern)(转)
摘要:在软件系统中,有些对象有时候由于跨越网络或者其他的障碍,而不能够或者不想直接访问另一个对象,如果直接访问会给系统带来不必要的复杂性,这时候可以在客户程序和目标对象之间增加一层中间层,让代理对象来 ...
- ios 编码转换 保存文件
- (NSString *)SaveFileToDocuments:(NSString *)url { // NSString *url = @"http://172.28.250.70/a ...
- 一道PK赛题
Problem Description I think that you might have played the traditional Chinese ring game: The Chines ...
- Android Environment FAQ (Frequently Asked Question)
1.how to find out the Eclipse Version From Eclipse Menu Help ----> About Eclipse It displayed as ...
- JAVA 异常对于性能的影响
陶炳哲 - MAY 12, 2015 在对OneAPM的客户做技术支持时,我们常常会看到很多客户根本没意识到的异常.在消除了这些异常之后,代码运行速度与以前相比大幅提升.这让我们产生一种猜测,就是在代 ...