2015 多校第四场 XYZ and Drops
来源:互联网 发布:数据库与缓存保持一致 编辑:程序博客网 时间:2024/06/05 19:15
# include <stdio.h># include <string.h># include <vector># include <queue>using namespace std;struct node{ int x,y; int de; node (int a,int b,int c) { x=a; y=b; de=c; }};const int MAXN=210;vector< pair<int,int> >::iterator it;int d[5][2]= {0,0,-1,0,1,0,0,-1,0,1};int r,c;//直接暴力模拟,注意题意:若水珠原来大小为3,恰好某一时刻有三个水珠到达,则六个小水珠同时碰撞产生四个方向的小水珠struct mapp{ int siz,time;} mp[MAXN][MAXN];vector <node> vec;queue <node> q;vector < pair<int,int> > ans;bool ok (int x,int y){ if(x>=1&&x<=r&&y>=1&&y<=c) return true; return false;}int main (){ int i,j,n,t,x,y,s,time; //freopen("1010.in","r",stdin); while(scanf("%d%d%d%d",&r,&c,&n,&t)!=EOF) { memset(mp,0,sizeof(mp)); ans.clear(); for(int i=1; i<=n; i++) { scanf("%d%d%d",&x,&y,&s); ans.push_back( make_pair(x,y) ); mp[x][y].siz=s; } scanf("%d%d",&x,&y); // printf("%d %d\n",x,y); while(!q.empty()) q.pop(); if(ok(x-1,y)) q.push(node(x-1,y,1)); if(ok(x+1,y)) q.push(node(x+1,y,2)); if(ok(x,y-1)) q.push(node(x,y-1,3)); if(ok(x,y+1)) q.push(node(x,y+1,4)); vec.clear(); for(time=1; time<=t; time++ ) { // printf("*****%d\n",time); for(int i=0; i<vec.size(); i++) { q.push(vec[i]); } vec.clear(); // printf("&&&%d\n",q.size()); while(!q.empty()) { node index=q.front(); q.pop(); x=index.x; y=index.y; // printf("%d %d\n",x,y); if(mp[x][y].siz!=0) { mp[x][y].siz++; } else { if(index.de==1&&ok(x-1,y)) vec.push_back(node(x-1,y,1)); if(index.de==2&&ok(x+1,y)) vec.push_back(node(x+1,y,2)); if(index.de==3&&ok(x,y-1)) vec.push_back(node(x,y-1,3)); if(index.de==4&&ok(x,y+1)) vec.push_back(node(x,y+1,4)); } } for(int i=0; i<n; i++) { x=ans[i].first; y=ans[i].second; if(mp[x][y].siz>4) { mp[x][y].siz=0; mp[x][y].time=time; if(ok(x-1,y)) vec.push_back(node(x-1,y,1)); if(ok(x+1,y)) vec.push_back(node(x+1,y,2)); if(ok(x,y-1)) vec.push_back(node(x,y-1,3)); if(ok(x,y+1)) vec.push_back(node(x,y+1,4)); } } } for(int i=0; i<n; i++ ) { if(mp[ans[i].first][ans[i].second].siz!=0) { printf("1 %d\n",mp[ans[i].first][ans[i].second].siz); } else { printf("0 %d\n",mp[ans[i].first][ans[i].second].time); } } } return 0;}
0 0
- 2015 多校第四场 XYZ and Drops
- 多校第四场 1010 hdu 5336 XYZ and Drops(bfs+模拟)
- HDU 5336 XYZ and Drops
- HDU 5336 XYZ and Drops
- 【HDOJ 5336】XYZ and Drops
- hdu 5336 XYZ and Drops
- hdu 5336 XYZ and Drops
- 【模拟】hdu5336 XYZ and Drops
- HDU 5336 XYZ and Drops
- Hdu 5336 XYZ and Drops
- HDU 5336 XYZ and Drops
- HDU 5336(2015多校4)-XYZ and Drops(bfs)
- HDOJ 5336 XYZ and Drops 模拟
- XYZ and Drops (hdu 5336 bfs)
- HDU 5336 XYZ and Drops(bfs)
- hdu 5336 XYZ and Drops 【BFS模拟】
- HDU5336 XYZ and Drops 暴力模拟
- hdu 5336 XYZ and Drops 模拟
- 在ubuntu中用apt-get安装LEMP栈(linux+nginx+mysql+php)
- 123
- poj 1077 八数码
- 色彩心理
- SSH学习 Hibernate 多对多
- 2015 多校第四场 XYZ and Drops
- cacti安装记录 第四阶段cacti的基本使用(2)Monitor插件的使用
- 机试算法讲解: 第9题 查找,对了,当然有哨兵
- poj 1274最大匹配匈牙利算法
- 【Github教程】史上最全github使用方法:github入门到精通
- JAVA学习的第三天
- android登陆界面的UI布局
- spring mvc配置文件
- java基础从零开始