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 分类:有源有汇 ...
随机推荐
- 01.Apache FtpServer配置
1.解压Apache FTPServer 将下载下来的压缩包(ftpserver-1.0.6.zip)解压到本地,其目录结构如下图: 2.修改users.properties 修改 \apache-f ...
- js判断手机还是pc并跳转相关页面
<script type="text/javascript"> function GetRequest() { var url = location.search; / ...
- 深入理解jQuery中live与bind方法的区别
本篇文章主要是对jQuery中live与bind方法的区别进行了详细的分析介绍,需要的朋友可以过来参考下,希望对大家有所帮助 注意如果是通过jq添加的层和对象一定要用live(),用其他的都不起作用 ...
- shell编程之echo命令
Linux echo命令不能显示文件中的内容.显示字符串或者变量功能说明:显示文字.语 法:echo [-ne][字符串]或 echo [--help][--version]补充说明:echo会将输入 ...
- 【BZOJ】【1150】【CTSC2007】数据备份Backup
堆/贪心 一共N-1个元素……用堆维护最大值,取了第x个元素以后,插入v[x-1]+v[x+1]-v[x]这个元素,如果再取这个新元素就表示不取x,而取x-1和x+1……大概就是这种“带反悔”的思路吧 ...
- RabbitMQ 3.6 安装
1. 首先安装这个 http://www.erlang.org/downloads 2. 再安装这个 http://www.rabbitmq.com/install-windows.html 3. 添 ...
- 图片放大镜插件 Cloud Zoom v3.1
Cloud Zoom是一个图像放大jQuery插件,效果堪比Magic Zoom.相对于流行jQZoom插件,Cloud Zoom体积小,有更多的功能和更强大的跨浏览器兼容性. 猛击这里查看演示DEM ...
- HDU1013Digital Roots
G - Digital Roots Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- c3p0 --2
c3p0号称是java界最好的数据池. c3p0的配置方式分为三种,分别是 1.setters一个个地设置各个配置项 2.类路径下提供一个c3p0.properties文件 3.类路径下提供一个c3p ...
- 旨在脱离后端环境的前端开发套件 - IDT Server篇
IDT,一个基于Nodejs的,旨在脱离后端环境的前端开发套件,目的就是能让前端开发完全脱离后端的环境,无论后端是什么模板引擎(主流),都能应付自如. IDT主要包括两大部分:Server + Bui ...