2015ACM多校对抗赛第四场 hdu 5336
来源:互联网 发布:node实战 编辑:程序博客网 时间:2024/04/30 02:03
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5336
XYZ and Drops
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1024 Accepted Submission(s): 291
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 T seconds, can you help him?
1≤r≤100 , 1≤c≤100 , 1≤n≤100 , 1≤T≤10000
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 (
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 followingn 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 integersx , 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).
Each line of the following
The next line contains two integers
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
If the
If the
Sample Input
4 4 5 102 1 42 3 32 4 43 1 24 3 44 4
Sample Output
0 50 30 21 30 1
题意:十滴水游戏的改版。
现在某个位置有一滴即将爆炸的水滴,爆炸后,将产生四个方向的四个小水滴,每一秒只能移动一步,这些小水滴要么出了表格边界,要么和其他水滴融合,被吸收。
当融合后的值达到5的时候,又会发生爆炸,问给定n个起始水滴的T时刻后的状态。0表示爆炸了+爆炸时刻。1表示没有爆炸+最后时刻水滴大小。
宽搜就行了,用优先队列维护,并标记。
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<queue>using namespace std;#define sf scanfconst int d[4][2]={1,0,0,1,-1,0,0,-1};struct node{ int t,x,y,d; bool operator<(const node &a)const{return t>a.t;}};struct point{ int x,y;}a[105];int r,c,n,T;priority_queue<node> que;int mapt[102][102];int ans[101][101];bool legel(int x,int y){return x>0&&x<=r&&y>0&&y<=c;}void addque(node p){ for(int i = 0;i<4;i++) { int xx = p.x + d[i][0]; int yy = p.y + d[i][1]; while(legel(xx,yy)&&mapt[xx][yy] == 0) {xx+=d[i][0];yy+=d[i][1];} //cout<<xx<<" "<<yy<<endl; if(mapt[xx][yy] != 0) { //cout<<xx<<","<<yy<<":"<<abs(xx+yy-p.x-p.y)+p.t<<endl; que.push(node{abs(xx+yy-p.x-p.y)+p.t,xx,yy,i}); } }}int main(){ while(~sf("%d%d%d%d",&r,&c,&n,&T)) { memset(mapt,0,sizeof mapt); memset(ans,0,sizeof ans); for(int i = 0;i<n;i++) { int x,y,z; sf("%d%d%d",&x,&y,&z); mapt[x][y] = z; a[i] = point{x,y}; } int x,y; sf("%d%d",&x,&y); while(!que.empty()) que.pop(); addque(node{0,x,y,0}); while(!que.empty()) { node p = que.top(); //cout<<p.t<<":"<<p.x<<","<<p.y<<"----------"<<endl; que.pop(); if(p.t>T) continue; if(mapt[p.x][p.y]<=4) { mapt[p.x][p.y]++; if(mapt[p.x][p.y]==5) { addque(p); ans[p.x][p.y] = p.t; } } else { if(ans[p.x][p.y] != p.t) { int xx = p.x + d[p.d][0]; int yy = p.y + d[p.d][1]; while(legel(xx,yy)&&mapt[xx][yy] == 0) {xx+=d[p.d][0];yy+=d[p.d][1];} if(mapt[xx][yy] != 0) { // cout<<xx<<","<<yy<<":"<<abs(xx+yy-p.x-p.y)+p.t<<endl; que.push(node{abs(xx+yy-p.x-p.y)+p.t,xx,yy,p.d}); } } } } for(int i =0;i<n;i++) if(ans[a[i].x][a[i].y]!=0) printf("0 %d\n",ans[a[i].x][a[i].y]); else printf("1 %d\n",mapt[a[i].x][a[i].y]); } return 0;}
0 0
- 2015ACM多校对抗赛第四场 hdu 5336
- 2015ACM多校对抗赛第四场 hdu 5327
- 2015ACM多校对抗赛第四场 hdu 5328
- 2015ACM多校对抗赛第四场 hdu 5335
- Hdu 5307 He is Fly 2015ACM多校对抗赛第二场
- Hdu 5344 MZL's xor 2015ACM多校对抗赛第五场
- Hdu 5346 MZL's game 2015ACM多校对抗赛第五场
- Hdu 5347 MZL's chemistry 2015ACM多校对抗赛第五场
- Hdu 5349 MZL's simple problem 2015ACM多校对抗赛第五场
- Hdu 5350 MZL's munhaff function 2015ACM多校对抗赛第五场
- Hdu 5351 MZL's Border 2015ACM多校对抗赛第五场
- 2015 ACM多校训练第四场
- HDU 5335(2015 ACM多校训练第四场1009)
- Hdu 5316 2015多校对抗赛三
- Hdu 5317 2015多校对抗赛三
- hdu 5318 2015多校对抗赛三
- hdu 5319 2015多校对抗赛三
- Hdu 5321 2015多校对抗赛三
- 2.2.1 命名空间;2.2.2 类
- Hadoop权威指南(中文第2版)PDF
- 最短路径——迪科斯彻算法(Dijkstra)算法
- LeetCode之Insertion Sort List
- 2015年网页设计的9大趋势
- 2015ACM多校对抗赛第四场 hdu 5336
- POJ 1573 Robot Motion(模拟)
- dos命令之find
- [日志分析]在nginx日志中,提取有效的request uri
- 【Win10】联想Z50-70升级到Win10,声音变成环绕声解决办法
- 织梦5.7DEDECMS标签大全
- 矩阵优化的模板(用的时候注意要修改呀)
- EJB学习笔记之十(BMT事务和CMT事务)
- jQuery FlexSlider插件的详细设置参数