HDU5336-XYZ and Drops-模拟
模拟水珠那个游戏。
小水珠超过边界会消失。
会有两个水珠同时到达一个size=4大水珠的情况。要移动完统一爆炸
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm> //using namespace std; const int maxn = +;
int r,c,n,T; int dx[] = {,,,-};
int dy[] = {,-,,}; struct dp
{
int x,y;
int dir;
bool die;
dp(int _x,int _y,int _dir):x(_x),y(_y),dir(_dir){
die = false;
}
bool out()
{
return (x < || x > r || y < || y > c);
}
void kill()
{
die = true;
}
void move()
{
x += dx[dir];
y += dy[dir];
if(out())
{
kill();
return ;
}
}
bool alive()
{
return !die;
}
};
std::vector <dp> drops; struct wdp
{
int x,y;
int siz;
int t;
int id;
void display()
{
printf("%d %d\n",siz==-? :,siz==-?t:siz);
}
void add(int tim)
{
if(siz == -) return ;
siz += ;
}
void split(int tim)
{
if(siz > )
{
siz = -;
t = tim;
//printf("time:%d %d crack\n",tim,id);
for(int i=;i<;i++)
{
drops.push_back(dp(x,y,i));
}
}
}
bool alive()
{
return siz != -;
}
}waterdrop[maxn]; bool merge(dp &a,wdp &b)
{
return (a.x == b.x && a.y == b.y);
} void roll(int tim)
{
int cnt = drops.size();
for(int i=;i<cnt;i++) if(drops[i].alive())
{
drops[i].move();
if(!drops[i].alive()) continue;
//printf("drops: [%d,%d]\n",drops[i].x,drops[i].y);
for(int j=;j<n;j++) if(waterdrop[j].alive())
{
if(merge(drops[i],waterdrop[j]))
{
waterdrop[j].add(tim);
drops[i].kill();
break ;
}
}
}
for(int i=;i<n;i++) waterdrop[i].split(tim);
} int main()
{
//freopen("input.txt","r",stdin);
while(~scanf("%d%d%d%d",&r,&c,&n,&T))
{
int x,y,siz;
drops.clear();
for(int i=;i<n;i++)
{
scanf("%d%d%d",&x,&y,&siz);
waterdrop[i].x = x;
waterdrop[i].y = y;
waterdrop[i].siz = siz;
waterdrop[i].id = i+;
}
scanf("%d%d",&x,&y);
for(int i=;i<;i++)
{
drops.push_back(dp(x,y,i));
}
for(int i=;i<=T;i++)
{
roll(i);
}
for(int i=;i<n;i++)
{
waterdrop[i].display();
}
}
}
想到了大一刚开始做的那个傻x坦克大战- -当时写一个判断子弹写半天
HDU5336-XYZ and Drops-模拟的更多相关文章
- Hdu 5336 XYZ and Drops (bfs 模拟)
题目链接: Hdu 5336 XYZ and Drops 题目描述: 有一个n*m的格子矩阵,在一些小格子里面可能会有一些水珠,每个小水珠都有一个size.现在呢,游戏开始咯,在一个指定的空的小格子里 ...
- 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)Tot ...
- HDU 5336——XYZ and Drops——————【广搜BFS】
XYZ and Drops Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- 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 2015 Multi-University Training Contest 4 1010
这题的题意是给你一幅图,图里面有水滴.每一个水滴都有质量,然后再给你一个起点,他会在一開始的时候向四周发射4个小水滴,假设小水滴撞上水滴,那么他们会融合,假设质量大于4了,那么就会爆炸,向四周射出质量 ...
- 2015 Multi-University Training Contest 4
1001 Olympiad 签到题1. # include <iostream> # include <cstdio> using namespace std; ]={}; b ...
- NOIP2014酱油记
尘埃落定,来补一下酱油记吧... day-1 晚上老师说有xyz的noip模拟赛,于是果断请假来做(shou)题(nve),题目真是理(S)性(X)愉(B)悦(K),然后就爆零了!感觉noip要爆零滚 ...
- 在PC上测试移动端网站和模拟手机浏览器的5大方
查了很多资料,尝试了大部分方法,下面将这一天的努力总结下分享给大家,也让大家免去看那么多文章,以下介绍的方法,都是本人亲自测试成功的方法,测试环境winxp. 一.Chrome*浏览器 chrome模 ...
- sqlmap --dns-domain模拟实践
因为看到乌云的这一篇文章 http://drop.xbclub.org/static/drops/tips-5283.html 里面的提到的用sqlmap 的--dns-domain 进行dns 注入 ...
- 模拟--poj1835宇航员的故事
这道题委实无语了,刚开始以为是很一般的方位模拟题,懒得看样例直接写的代码,然后敲了好几个switch结果样例居然没出来.. 仔细分析了样例之后才发现原来随着宇航员方位的改变他的左手方向以及头顶方向是跟 ...
随机推荐
- Git基本使用命令
整理Git的一些基本使用命令. # 1)克隆代码 boldseas@lian-PC MINGW64 /d/TestGroup $ git clone ssh://git@code.boldseas ...
- JavaScript Patterns 2.11 Writing Comments
Document all functions, their arguments and return values, and also any interesting or unusual algor ...
- 魔改——MFC SDI程序 转换为 MDI程序
==================================声明================================== 本文原创,转载在正文中显要的注明作者和出处,并保证文章的完 ...
- 使用NDK c++建立一个Android应用
使用NDK c++建立一个Android应用 一.工具 ADT(集成了eclipse,cdt,ndk plug-in) NDK (用它来编译c/c++程序) JDK (Java开发包) ANT(ecl ...
- Windows系统镜像自动添加驱动程序
2016年到了一家公司做网管,经常会为了装系统而烦恼,后来学习了WDS自动部署,但是在学习过程中发现启动镜像boot.wim中没有网卡驱动 导致wds报错,后来经过网上查找相关资料学会了如何向系统里添 ...
- 探索 OpenStack 之(12):cinder-api Service 处理 HTTP Request 的过程分析
本文是上一篇 探索 OpenStack 之(11):cinder-api Service 启动过程分析 以及 WSGI / Paste deploy / Router 等介绍> 的后续篇. os ...
- NOIP2014提高组 DAY1 -SilverN
T1 生活大爆炸版石头剪刀布 题目描述 石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头.如果两个人出拳一样,则不分胜负.在<生活大爆炸>第二季第8 集中出现了一种石头剪刀布的 ...
- runc kill 和 delete流程分析
runc kill // kill sends the specified signal (default: SIGTERM) to the container's init process 1.ru ...
- pixel art之 hqx 算法
在去年的时候,偶然看到hqx算法. 一个高质量的插值放大算法. 与双线性插值等插值算法相比,这个算法放大后对人眼保护相对比较好. 没有双线性插值看起来模糊,固然,也抽空把算法简单优化了一下. 官网及代 ...
- bfs简单题-poj2251
宽搜基础题 思路很简单,注意细节. 走过的节点一定要打上标记//tag数组 三维字符串输入一定要注意 #include <stdio.h> #include <iostream> ...