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 ;
}
上一篇:全方位理解Android权限之底层实现概览


下一篇:Python学习笔记001——Linux