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 分类:有源有汇 ...
随机推荐
- Leetcode#115 Distinct Subsequences
原题地址 转化为求非重路径数问题,用动态规划求解,这种方法还挺常见的 举个例子,S="aabb",T="ab".构造如下地图("."表示空位 ...
- 数据类型的处理(提取自FMDB)
if ((!obj) || ((NSNull *)obj == [NSNull null])) { sqlite3_bind_null(pStmt, idx); } // FIXME - someda ...
- 利用PE数据目录的导入表获取函数名及其地址
PE文件是以64字节的DOS文件头开始的(IMAGE_DOS_HEADER),接着是一段小DOS程序,然后是248字节的 NT文件头(IMAGE_NT_HEADERS),NT的文件头位置由IMAGE_ ...
- 您可能不知道的ASP.Net小技巧
<!-- 页码和简介 --> 1. 在提交页面之后,保持滚动条的位置 可以在page指令上加上MaintainScrollPositionOnPostback指令 <%@ Page ...
- 遭遇Asp.Net长文件名下载的问题和解决办法
在Asp.Net中写了一个附件上传和下载的程序,附件上传到数据库中,然后将附件的GUID保存起来,我们可以根据GUID来找到数据库中的附件,一般附件下载的代码是: <!--<br /> ...
- ibatis中iterate的用法(conjunction="or" ",")
例子一 查询条件dto public class queryCondition{ private String[] stuIds; private String name;} 查询sqlMap < ...
- iOS KVC,KVO
链接(写得不错,着重kvc):http://www.cocoachina.com/industry/20140224/7866.html 链接:http://www.cnblogs.com/kensh ...
- iOS自定义发送消息输入框
简单的封装了一个,免得麻烦直接初始化就可以用了 ,有其他需求该里面参数就行了 WJEasyInputTextView.h , CGRectGetHeight([UIScreen mainScreen] ...
- 树莓派/RaspberryPi 内核编译
1.获取所需源码 1)下载地址: 官方网址:https://github.com/raspberrypi 上面列出了树莓派所有的开源软件: linux:内核源码 tools:编译内核和其他源码所需的工 ...
- Jquery---用jQuery实现的智能隐藏、滑动效果的返回顶部代码
<script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.7.2.min.js"></script& ...