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

Problem Description
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 Tseconds, can you help him?

1≤r≤100, 1≤c≤100, 1≤n≤100, 1≤T≤10000

 
Input
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).

 
Output
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.
 
Sample Input
4 4 5 10
2 1 4
2 3 3
2 4 4
3 1 2
4 3 4
4 4
 
Sample Output
0 5
0 3
0 2
1 3
0 1
 
Author
XJZX
 
Source
 
解题:直接模拟爆炸情况。。。
 
 #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的更多相关文章

  1. Hdu 5336 XYZ and Drops (bfs 模拟)

    题目链接: Hdu 5336 XYZ and Drops 题目描述: 有一个n*m的格子矩阵,在一些小格子里面可能会有一些水珠,每个小水珠都有一个size.现在呢,游戏开始咯,在一个指定的空的小格子里 ...

  2. HDU 5336 XYZ and Drops 2015 Multi-University Training Contest 4 1010

    这题的题意是给你一幅图,图里面有水滴.每一个水滴都有质量,然后再给你一个起点,他会在一開始的时候向四周发射4个小水滴,假设小水滴撞上水滴,那么他们会融合,假设质量大于4了,那么就会爆炸,向四周射出质量 ...

  3. HDU 5336 XYZ and Drops

    Problem Description XYZ is playing an interesting game called "drops". It is played on a r ...

  4. HDU 5336——XYZ and Drops——————【广搜BFS】

    XYZ and Drops Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  5. 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 ...

  6. 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:  ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. springMVC传递对象参数

    初学java,由于项目紧急,来不及仔细的研究,在传递参数时就老老实实的一个一个的采用@RequestParam注解方式传递,最近认真看了一下,发现java也具有类似Asp.net Mvc传递对象做参数 ...

  2. Vue学习之路第三篇:插值表达式和v-text的区别

    上一篇说到插值表达式有一个问题: 页面频繁刷新或者网速加载很慢的时候,页面会先出现“{{ msg }}”,再一闪而过出现真实的数据. 对于这个问题Vue给予了解决办法,看具体事例. <div i ...

  3. [luogu4133 BJOI2012] 最多的方案 (计数dp)

    题目描述 第二关和很出名的斐波那契数列有关,地球上的OIer都知道:F1=1, F2=2, Fi = Fi-1 + Fi-2,每一项都可以称为斐波那契数.现在给一个正整数N,它可以写成一些斐波那契数的 ...

  4. nysql数据库优化

    硬件优化 软件优化 my.cnf参数优化,命令监控show global status\G 调优工具mysqlreport sql语句优化 索引的优化 白名单机制--百度,就是让一些不规范的语句执行查 ...

  5. 安装Nginx的各种报错的解决

    如题,本人环境Ubuntu14.0虚拟机,安装一个nginx服务器来运行我的fastDfs文件管理的.但是安装出现了各种问题: sudo ./configure --prefix=/usr/local ...

  6. ASP.NET-关于Global.asax的作用

    这个文件相当于一个应用程序量级的 全局文件,比如你想写一个变量在项目中的所有文件中都能读取是就写在这里面 Application["name"] = "zhangran& ...

  7. 华硕 X201E 拆机

    每次笔记本拆机,装好之后.就会发现多了几个螺丝,忘了从哪拧下来了 以下记录下华硕 X201E 清灰拆机过程 1:电脑正面图 2:背面图,一共9个螺丝 3:背面的9个螺丝拧下来,把后盖沿着缝隙扣下来 w ...

  8. Android实现天气预报温度/气温折线趋势图

     Android实现天气预报温度/气温折线趋势图 天气预报的APP应用中,难免会遇到绘制天气温度/气温,等关于数据趋势的折线或者曲线图,这类关于气温/温度的折线图,通常会有两条线.一条是高温线,一 ...

  9. ShellExcuteA

    ShellExecuteA(,//0表示系统打开 "open",//操作 "1.mp3",//操作路径 0,//第四个,第五个参数都是保留参数,默认都为0 0, ...

  10. Ubuntu16.04+GTX 1080Ti+CUDA 8.0+cuDNN+Tesnorflow1.0深度学习服务器安装之路

    0.安装背景 系统:ubuntu 16.04 内核:4.4.0-140-generic GPU:GTX 1080Ti nvidia驱动版本: 384.111 cuda: CUDA 8.0 深度学习库c ...