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)
Total Submission(s): 505 Accepted Submission(s): 122
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 Tseconds, can you help him?
1≤r≤100, 1≤c≤100, 1≤n≤100, 1≤T≤10000
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).
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.
#include <bits/stdc++.h>
using namespace std;
const int maxn = ;
const int dir[][] = {-,,,-,,,,};
int mp[maxn][maxn],r,c,n,T,x,y;
struct waterdrop {
int x,y,sz,btime;
bool crack;
waterdrop(int a = ,int b = ,int c = ,int d = ) {
x = a;
y = b;
sz = c;
btime = d;
}
} wp[maxn];
struct drop {
int x,y,time,o;
drop(int a = ,int b = ,int c = ,int d = ) {
x = a;
y = b;
time = c;
o = d;
}
};
queue<drop>q;
bool isIn(int x,int y) {
return x > && x <= r && y > && y <= c;
}
void bfs() {
for(int i = ; i < ; ++i)
q.push(drop(x,y,,i));
while(!q.empty()) {
drop cur = q.front();
q.pop();
if(cur.time >= T) return;
int nx = cur.x + dir[cur.o][];
int ny = cur.y + dir[cur.o][];
if(!isIn(nx,ny)) continue;
int idx = mp[nx][ny];
if(idx == - || wp[idx].crack && wp[idx].btime != cur.time+) q.push(drop(nx,ny,cur.time+,cur.o));
else if(!wp[idx].crack) {
wp[idx].sz++;
if(wp[idx].sz > ) {
wp[idx].crack = true;
wp[idx].btime = cur.time+;
for(int k = ; k < ; ++k)
q.push(drop(wp[idx].x,wp[idx].y,cur.time+,k));
}
}
}
}
int main() {
while(~scanf("%d%d%d%d",&r,&c,&n,&T)) {
memset(mp,-,sizeof mp);
while(!q.empty()) q.pop();
for(int i = ; i < n; ++i) {
scanf("%d%d%d",&wp[i].x,&wp[i].y,&wp[i].sz);
wp[i].crack = false;
mp[wp[i].x][wp[i].y] = i;
if(wp[i].sz > ) {
wp[i].crack = true;
wp[i].btime = ;
for(int k = ; k < ; ++k)
q.push(drop(wp[i].x,wp[i].y,,k));
}
}
scanf("%d%d",&x,&y);
bfs();
for(int i = ; i < n; ++i)
printf("%d %d\n",!wp[i].crack,wp[i].crack?wp[i].btime:wp[i].sz);
}
return ;
}
2015 Multi-University Training Contest 4 hdu 5336 XYZ and Drops的更多相关文章
- Hdu 5336 XYZ and Drops (bfs 模拟)
题目链接: Hdu 5336 XYZ and Drops 题目描述: 有一个n*m的格子矩阵,在一些小格子里面可能会有一些水珠,每个小水珠都有一个size.现在呢,游戏开始咯,在一个指定的空的小格子里 ...
- HDU 5336 XYZ and Drops 2015 Multi-University Training Contest 4 1010
这题的题意是给你一幅图,图里面有水滴.每一个水滴都有质量,然后再给你一个起点,他会在一開始的时候向四周发射4个小水滴,假设小水滴撞上水滴,那么他们会融合,假设质量大于4了,那么就会爆炸,向四周射出质量 ...
- HDU 5336 XYZ and Drops
Problem Description XYZ is playing an interesting game called "drops". It is played on a r ...
- 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 8 hdu 5390 tree
tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...
- 2015 Multi-University Training Contest 8 hdu 5383 Yu-Gi-Oh!
Yu-Gi-Oh! Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: ...
- 2015 Multi-University Training Contest 8 hdu 5385 The path
The path Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 5 ...
- 2015 Multi-University Training Contest 3 hdu 5324 Boring Class
Boring Class Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- 2015 Multi-University Training Contest 3 hdu 5317 RGCDQ
RGCDQ Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submi ...
随机推荐
- 51nod 1576 Tree and permutation(树的重心+dfn序)
乍一看我不会. 先不考虑加点. 先考虑没有那个除\(2\). 考虑每一条边的贡献,假设某一条边把这棵树分成大小为x,y的两个部分. 那么这条边最多可以被使用\(min(x,y)*2\)次(因为有进有出 ...
- 【codeforces 794C】Naming Company
[题目链接]:http://codeforces.com/contest/794/problem/C [题意] 有n个位置; 两个人; 每个人都有n个字符组成的集合s1,s2(可以有重复元素); 然后 ...
- Executors线程池关闭时间计算
Executors线程池关闭时间计算 学习了:http://blog.csdn.net/wo541075754/article/details/51564359 https://www.cnblogs ...
- Java String内存释放
Java String内存释放 这是一个坑,Java对于String对象,不进行内存的回收: 处理大数据量的时候,少用String. 与JDK有关系:jdk1.6环境下,内存只占用10M,jdk1.8 ...
- TS 函数解析
------------------------------------------------------------------------------------ 函数传参: //let myA ...
- PyCharm基本设置、常用快捷键
1. 下载安装 PyCharm官方下载地址: https://www.jetbrains.com/pycharm/download/index.html#section=windows 安装完成后在 ...
- shiro什么时候会进入doGetAuthorizationInfo(PrincipalCollection principals)
shiro会进入授权方法一共有三种情况!(注解.标签.代码) 1.subject.hasRole(“admin”) 或 subject.isPermitted(“admin”):自己去调用这个是否有什 ...
- 线程进阶:多任务处理(17)——Java中的锁(Unsafe基础)
在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...
- Windows窗体应用布局详解
上回我们已经会用基本的控件创建Windows窗体应用,这才我们再来认识一些高级控件并使用ADO.NET技术连接数据库来创建功能更坚强大的窗体应用! 菜单栏控件MenuStrip .NET中提供了一个M ...
- sql server 查询某个表一直显示"正在执行中..."的问题
问题描述:只是单纯的执行了"select count(*) from 某表":数据表中只有一两条数据,能查询其他表,唯独这个表不能进行任何操作: 经百度搜索实验,发现应该是某个进程 ...