HDU 5336 XYZ and Drops
XYZ is playing an interesting game called "drops". It is played on a r∗c grid. Each grid cell is either empty, or occupied by a waterdrop. Each waterdrop has a property "size". The waterdrop cracks when its size is larger than 4, and produces 4 small drops moving towards 4 different directions (up, down, left and right). In every second, every small drop moves to the next cell of its direction. It is possible that multiple small drops can be at same cell, and they won't collide. Then for each cell occupied by a waterdrop, the waterdrop's size increases by the number of the small drops in this cell, and these small drops disappears. You are given a game and a position (x, y), before the first second there is a waterdrop cracking at position (x, y). XYZ wants to know each waterdrop's status after T seconds, can you help him? 1≤r≤100, 1≤c≤100, 1≤n≤100, 1≤T≤10000
The first line contains four integers r, c, n and T. n stands for the numbers of waterdrops at the beginning.
Each line of the following n lines contains three integers xi, yi, sizei, meaning that the i-th waterdrop is at position (xi, yi) and its size is sizei. (1≤sizei≤4)
The next line contains two integers x, y. It is guaranteed that all the positions in the input are distinct. Multiple test cases (about 100 cases), please read until EOF (End Of File).
n lines. Each line contains two integers Ai, Bi:
If the i-th waterdrop cracks in T seconds, Ai=0, Bi= the time when it cracked.
If the i-th waterdrop doesn't crack in T seconds, Ai=1, Bi= its size after T seconds.
4 4 5 10
2 1 4
2 3 3
2 4 4
3 1 2
4 3 4
4 4
0 5
0 3
0 2
1 3 0 1 来个优先级队列记录一下时间,暴力的搞吧#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<algorithm>
#include<string>
#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
using namespace std;
const ll maxn=105;
int T,n,m,t,f[maxn][maxn],x,y,a[maxn],b[maxn],c[maxn][maxn]; struct point
{
int x,y,z,t,now;
point(){}
point(int x,int y,int z,int t,int now):
x(x),y(y),z(z),t(t),now(now) {};
bool operator <(const point &a) const
{
return now+t>a.now+a.t;
}
}; int get(int x,int y,int d)
{
if (d&1)
{
if (d==1)
{
for (int i=y+1;i<=m;i++)
if (f[x][i]) return i-y;
return 0;
}
else
{
for (int i=y-1;i>=1;i--)
if (f[x][i]) return y-i;
return 0;
}
}
else
{
if (d==0)
{
for (int i=x-1;i>=1;i--)
if (f[i][y]) return x-i;
return 0;
}
else
{
for (int i=x+1;i<=n;i++)
if (f[i][y]) return i-x;
return 0;
}
}
} int main()
{
//scanf("%d",&T);
while (~scanf("%d%d%d%d",&n,&m,&t,&T))
{
memset(f,0,sizeof(f));
memset(c,0,sizeof(c));
for (int i=1;i<=t;i++)
{
scanf("%d%d",&x,&y);
a[i]=x; b[i]=y;
scanf("%d",&f[x][y]);
}
scanf("%d%d",&x,&y);
priority_queue<point> p;
for (int i=0;i<4;i++)
{
int k=get(x,y,i);
if (k>0) p.push(point(x,y,i,k,0));
}
while (!p.empty())
{
point tp,q=p.top(); p.pop(); for (;;p.pop())
{
if (p.empty()) break;
tp=p.top();
if(tp.now+tp.t!=q.now+q.t) break;
int k=get(tp.x,tp.y,tp.z);
if (!k) continue;
if (k!=tp.t) p.push(point(tp.x,tp.y,tp.z,k,tp.now));
else
{
if (k+tp.now>T) break;
if (tp.z==0) x=tp.x-k,y=tp.y;
if (tp.z==1) x=tp.x,y=tp.y+k;
if (tp.z==2) x=tp.x+k,y=tp.y;
if (tp.z==3) x=tp.x,y=tp.y-k;
f[x][y]++;
}
}
int k=get(q.x,q.y,q.z);
if (k)
if (k!=q.t) p.push(point(q.x,q.y,q.z,k,q.now));
else
{
if (k+q.now>T) break;
if (q.z==0) x=q.x-k,y=q.y;
if (q.z==1) x=q.x,y=q.y+k;
if (q.z==2) x=q.x+k,y=q.y;
if (q.z==3) x=q.x,y=q.y-k;
f[x][y]++;
}
for(int i=1;i<=t;i++)
{
x=a[i]; y=b[i];
if (f[x][y]>4)
{
f[x][y]=0;
c[x][y]=q.t+q.now;
for (int j=0;j<4;j++)
{
int u=get(x,y,j);
if (u>0) p.push(point(x,y,j,u,q.t+q.now));
}
}
}
}
for (int i=1;i<=t;i++)
{
if (f[a[i]][b[i]]) printf("1 %d\n",f[a[i]][b[i]]);
else printf("0 %d\n",c[a[i]][b[i]]);
}
}
return 0;
}
HDU 5336 XYZ and Drops的更多相关文章
- Hdu 5336 XYZ and Drops (bfs 模拟)
题目链接: Hdu 5336 XYZ and Drops 题目描述: 有一个n*m的格子矩阵,在一些小格子里面可能会有一些水珠,每个小水珠都有一个size.现在呢,游戏开始咯,在一个指定的空的小格子里 ...
- HDU 5336——XYZ and Drops——————【广搜BFS】
XYZ and Drops Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- 2015 Multi-University Training Contest 4 hdu 5336 XYZ and Drops
XYZ and Drops Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- HDU 5336 XYZ and Drops 2015 Multi-University Training Contest 4 1010
这题的题意是给你一幅图,图里面有水滴.每一个水滴都有质量,然后再给你一个起点,他会在一開始的时候向四周发射4个小水滴,假设小水滴撞上水滴,那么他们会融合,假设质量大于4了,那么就会爆炸,向四周射出质量 ...
- 2015 多校赛 第四场 1010 (hdu 5336)
Problem Description XYZ is playing an interesting game called "drops". It is played on a r ...
- 2015 Multi-University Training Contest 4
1001 Olympiad 签到题1. # include <iostream> # include <cstdio> using namespace std; ]={}; b ...
- HDU 3213 Box Relations(拓扑排序构造)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3231 题意:有n个长方体,四种限制条件.(1)I x y x和y有相交:(2)X/Y/Z x y x ...
- HDU 4282 A very hard mathematic problem 二分
A very hard mathematic problem Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/sh ...
- HDU 5874 Friends and Enemies 【构造】 (2016 ACM/ICPC Asia Regional Dalian Online)
Friends and Enemies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
随机推荐
- 1.7(SQL学习笔记)游标
一.游标简介 SELECT语句得到的是一个结果集,有时我们需要对结果集中的单条数据进行处理. 这时就需要使用游标,游标定义时和一个SELECT语句的结果集关联在一起. 游标执行这个结果集,可以在结果集 ...
- bzoj2938 病毒
Description 二进制病毒审查委员会最近发现了如下的规律:某些确定的二进制串是病毒的代码.如果某段代码中不存在任何一段病毒代码,那么我们就称这段代码是安全的.现在委员会已经找出了所有的病毒代码 ...
- [转]ADT中通过DDMS导入文件出错ddms transfer error: Read-only file system,Failed to push selection: Read-only file system
[已解决] 原文 http://www.crifan.com/ddms_import_file_error_transfer_error_read_only_file_system/ 想要通过adt ...
- bzoj 3224 普通平衡树 vactor的妙用
3224: Tyvj 1728 普通平衡树 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/ ...
- JS 判断PC、android、ios、微信浏览器
1.通过js userAgent来判断 <h1>判断访问此链接的操作系统</h1> <script> var Agents = new Array("An ...
- 关于利用ajax时,设置访问延时的方法
在实际开发中应使用后端的延时方法,一般为sleep,可以设置延时几秒后返回给前端请求的数据 众所周知,在js中,并不存在例如C++或者JAVA.PHP中的sleep延时方法, 目前仅有的所谓延时方法S ...
- Tasker 正则表达式测试器
http://tieba.baidu.com/p/3533498043 本次分享的是一个正则表达式测试工具,用来方便快捷的进行Tasker正则方面的测试,一些比较复杂的匹配需要进行多次尝试才可能正确匹 ...
- JLInk 各种版本图片收集
所有图片来自网络, 版权归原始所有者拥有. JLink V5 JLink V6 JLink V7 JLink V8 JLink V9 JLink Ultra JLink Pro
- 严重: StandardServer.await: create[8005]:
严重: StandardServer.await: create[8005]: 2011-03-14 17:44:51| 分类: 默认分类 | 标签:tomcat java 端口 await crea ...
- 腾讯PHP工程师面试题两份
试题一: PHP开发工程师笔试试卷 姓名:__________ 一.PHP开发部分 1.合并两个数组有几种方式,试比较它们的异同 2.请写一个函数来检查用户提交的数据是否为整数(不区分数据类型,可以为 ...