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 ...
随机推荐
- 使用 Jersey 和 Apache Tomcat 构建 RESTful Web 服务
作者: Yi Ming Huang, 软件工程师, IBM Dong Fei Wu, 软件工程师, IBM Qing Guo, 软件工程师, IBM 出处: http://www.ibm.com/de ...
- shell试题
1.按单词出现频率降序排序! 2.按字母出现频率降序排序! The months of learning in Old Boy education are the few months that I ...
- mysql局域网服务搭建
首先配置电脑Mysql环境变量 新建 Mysql服务配置 CMD >命令 : mysql -u root -p 4. 创建用户 Mysql 用户权限分配 5 重启服务 如果还不能访问就一定是你的 ...
- PHP中的 Iterator 与 Generator
在讲解生成器之前先介绍一下迭代器: 在 PHP 中,通常情况下遍历数组使用 foreach 来遍历. 如果我们要想让一个对象可以遍历呢? PHP 为我们提供了 Iterator 接口,只要实现了这个接 ...
- SpringBoot+Maven聚合多项目打包成jar
已我最近自己在玩的一个DEMO为例 taosir为pom.xml,其他子项目均为其modules,且为jar项目 eureka为注册中心.workflow为提供者.entrance为调用方 entra ...
- Mysql学习总结(31)——MySql使用建议,尽量避免这些问题
做服务器端开发的同学们,相信对于mysql应该是十分熟悉,但是一旦真正出现问题,你是否能够快速的发现问题的起因,并且解决呢?一旦问题涉及到数据库层面,往往不是那么好解决的,通常来说,我们需要提前做应对 ...
- C/C++拾遗(一):关于数组的指针和数组元素首地址的一道经典题
代码例如以下: #include <stdio.h> int main(void) { int a[5] = {1, 2, 3, 4, 5}; int *ptr = (int *)(&am ...
- 百度 谷歌 Twitter,这么多短链接服务(Short Url)究竟哪家强?
一.短链接是什么 url=HPqdQ5VR3vA39x7ZWoWyNzwWnsDhTbh66BTpdzsJLroBDzFRm4JV-G818Zc027uZrwe7zxtxnD4H2FUahftpUK& ...
- Centos yum 安装lamp PHP5.4版本号
centos 6.5 1.yum安装和源码编译在使用的时候没啥差别.可是安装的过程就大相径庭了,yum仅仅须要3个命令就能够完毕,源码须要13个包,还得加压编译.步骤非常麻烦,并且当做有时候会出错,源 ...
- 如何使用scss/sass
SCSS 与 Sass 异同:http://sass.bootcss.com/docs/scss-for-sass-users/: 欢迎加入前端交流群来py: 转载请标明出处! 废话不多说,直接进入正 ...