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结果样例居然没出来.. 仔细分析了样例之后才发现原来随着宇航员方位的改变他的左手方向以及头顶方向是跟 ...
随机推荐
- Effective Java 36 Consistently use the Override annotation
Principle Use the Override annotation on every method declaration that you believe to override a sup ...
- LU分解,Javascript代码
///A 为矩阵,这里写成一维数组,如 [1],[1,2,3,4] function GetLU(a) { var n = a.length;//矩阵的总数据数目 var s = Math.sqrt( ...
- c#的序列化与反序列化
这是反序列化的代码 using System.Runtime.Serialization.Json; public static T deserialize<T>(String s) { ...
- POJ3648 A Simple Problem with Integers(线段树之成段更新。入门题)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 53169 Acc ...
- C++find函数
头文件 #include <algorithm> 函数实现 template<class InputIterator, class T> InputIterator find ...
- [麦先生]学习PDO循序渐进使用方式
使用方式 特点一:支持跨数据库 1:首先实例化PDO,创建PDO对象的四个必备参数:host(哪一种类型的数据库,mysql/orcal/SQLserver等);dbname(数据库的名称);cha ...
- TestNG之执行测试类方式
TestNG提供了很多执行方式,下面做简单介绍. 1.XML指明测试类,按照类名执行,其中可以指定包名,也可指定无包名: 带包名,运行ParameterSample类和ParameterTest类 & ...
- HTML5性能优化
HTML5性能优化 在看完这两章内容之后,我意犹未尽,于是乎从网上搜索关键字“Java Web高性能”,在IBM社区找到两篇不错的文章,而让人更意外的是我发现那两篇文章的内容跟<高性能HTML5 ...
- 分析递归式 Solving Recurrences------GeeksforGeeks 翻译
在上一章中我们讨论了如何分析循环语句.在现实中,有很多算法是递归的,当我们分析这些算法的时候我们要找到他们的的递归关系.例如归并排序,为了排序一个数组,我们把它平均分为两份然后再重复平分的步骤.最后我 ...
- [ZZ]风险驱动的测试
http://googletesting.blogspot.com/2014/05/testing-on-toilet-risk-driven-testing.html Testing on the ...