[bzoj1033] [ZJOI2008]杀蚂蚁 Big MoNI
这个模拟就不用说了吧......
注意事项(救命的):1.不能回原位 2.在可以打到target的塔打target的时候,其他打不到的继续打自己的(这是显然的事情只是当时已惘然) 3.如果游戏在某一秒结束,那么这一秒年龄不加 4.蚂蚁半径0.5 5.蚂蚁窝上不能有蚂蚁 6.HP别加爆,信息素别减爆 7.如果一只蚂蚁被卡了那么他也可能是被卡在蛋糕那里,也就是上一个死了,他被卡了,他就拿到了
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
inline int read()
{
int sum=;
char ch=getchar();
while(ch<''||ch>'')ch=getchar();
while(ch>=''&&ch<='')
{
sum=(sum<<)+(sum<<)+ch-'';
ch=getchar();
}
return sum;
}
typedef long double LD;
LD Source_HP[];
const LD eps=1e-;
int Now_Rank=,Rank_In;
int Information[][];
int pos[][];
int s,d,r;
int target;
struct Ant
{
int S_HP,HP,x,y,old,id,X,Y;
}ant[];
struct Tor
{
int x,y;
}tor[];
int t,T,n,m;
int ant_now;
int go1[]={,,,-};
int go2[]={,,-,};
inline void Read()
{
n=read(),m=read(),s=read(),d=read(),r=read();
for(int i=;i<=s;i++)tor[i].x=read(),tor[i].y=read(),pos[tor[i].x][tor[i].y]=;
T=read();
Source_HP[]=4.0;
for(int i=;i<;i++)Source_HP[i]=Source_HP[i-]*1.1;
}
inline int SQR(int x)
{
return x*x;
}
inline LD Sqr(LD x)
{
return x*x;
}
int main()
{
Read();
while(t<T)
{
++t;
if(ant_now<&&(pos[][]==))
{
++ant_now;
ant[ant_now].x=ant[ant_now].y=ant[ant_now].old=;
ant[ant_now].X=ant[ant_now].Y=-;
pos[][]=;
ant[ant_now].S_HP=ant[ant_now].HP=(int)(Source_HP[Now_Rank]);
ant[ant_now].id=Now_Rank;
++Rank_In;
if(Rank_In==)
Rank_In=,++Now_Rank;
}
for(int i=;i<=ant_now;i++)Information[ant[i].x][ant[i].y]+=(i==target)?:;
for(int i=;i<=ant_now;i++)
{
int to=-,key=-;
if(ant[i].y!=m&&pos[ant[i].x+go1[]][ant[i].y+go2[]]==&&Information[ant[i].x+go1[]][ant[i].y+go2[]]>key&&((ant[i].x+go1[]==ant[i].X&&ant[i].y+go2[]==ant[i].Y)==))
to=,key=Information[ant[i].x+go1[]][ant[i].y+go2[]];
if(ant[i].x!=n&&pos[ant[i].x+go1[]][ant[i].y+go2[]]==&&Information[ant[i].x+go1[]][ant[i].y+go2[]]>key&&((ant[i].x+go1[]==ant[i].X&&ant[i].y+go2[]==ant[i].Y)==))
to=,key=Information[ant[i].x+go1[]][ant[i].y+go2[]];
if(ant[i].y!=&&pos[ant[i].x+go1[]][ant[i].y+go2[]]==&&Information[ant[i].x+go1[]][ant[i].y+go2[]]>key&&((ant[i].x+go1[]==ant[i].X&&ant[i].y+go2[]==ant[i].Y)==))
to=,key=Information[ant[i].x+go1[]][ant[i].y+go2[]];
if(ant[i].x!=&&pos[ant[i].x+go1[]][ant[i].y+go2[]]==&&Information[ant[i].x+go1[]][ant[i].y+go2[]]>key&&((ant[i].x+go1[]==ant[i].X&&ant[i].y+go2[]==ant[i].Y)==))
to=,key=Information[ant[i].x+go1[]][ant[i].y+go2[]];
if(to==-)
{
ant[i].X=ant[i].x;
ant[i].Y=ant[i].y;
if(target==&&ant[i].x==n&&ant[i].y==m)
target=i,ant[i].HP=(ant[i].HP+(ant[i].S_HP>>))>=ant[i].S_HP?ant[i].S_HP:(ant[i].HP+(ant[i].S_HP>>));
continue;
}
if((ant[i].old+)%==)
{
to=(to==)?:(to-);
while()
if(ant[i].x+go1[to]>=&&ant[i].x+go1[to]<=n&&ant[i].y+go2[to]>=&&ant[i].y+go2[to]<=m&&pos[ant[i].x+go1[to]][ant[i].y+go2[to]]==&&(ant[i].x+go1[to]==ant[i].X&&ant[i].y+go2[to]==ant[i].Y)==)
break;
else
to=(to==)?:(to-);
}
ant[i].X=ant[i].x;
ant[i].Y=ant[i].y;
pos[ant[i].x+go1[to]][ant[i].y+go2[to]]=;
pos[ant[i].x][ant[i].y]=;
if(target==&&ant[i].x+go1[to]==n&&ant[i].y+go2[to]==m)
target=i,ant[i].HP=(ant[i].HP+(ant[i].S_HP>>))>=ant[i].S_HP?ant[i].S_HP:(ant[i].HP+(ant[i].S_HP>>));
ant[i].x=ant[i].x+go1[to];
ant[i].y=ant[i].y+go2[to];
}
if(target)
{
for(int i=;i<=s;i++)
if(SQR(ant[target].x-tor[i].x)+SQR(ant[target].y-tor[i].y)<=SQR(r))
{
int a=ant[target].y-tor[i].y,b=tor[i].x-ant[target].x,c=tor[i].y*(ant[target].x-tor[i].x)+tor[i].x*(tor[i].y-ant[target].y);
if(b!=)
{
LD Ki=0.0-(LD)a/b,Bi=0.0-(LD)c/b;
int l=ant[target].x<tor[i].x?ant[target].x:tor[i].x,r=ant[target].x>tor[i].x?ant[target].x:tor[i].x;
for(int j=;j<=ant_now;j++)
if(SQR(a*ant[j].x+b*ant[j].y+c)<=0.25*(SQR(a)+SQR(b)))
{
LD A=(1.0+Sqr(Ki)),B=2.0*Ki*(Bi-ant[j].y)-2.0*ant[j].x,C=Sqr(Bi-ant[j].y)+Sqr(ant[j].x)-0.25;
LD X1=(-B-sqrt(Sqr(B)-4.0*A*C))/(2.0*A),X2=(-B+sqrt(Sqr(B)-4.0*A*C))/(2.0*A);
if((l-eps<=X1&&r+eps>=X1)||(l-eps<=X2&&r+eps>=X2))ant[j].HP-=d;
}
}
else
{
LD Ni=(LD)c/a;
int l=ant[target].y<tor[i].y?ant[target].y:tor[i].y,r=ant[target].y>tor[i].y?ant[target].y:tor[i].y;
for(int j=;j<=ant_now;j++)
if(SQR(a*ant[j].x+b*ant[j].y+c)<=0.25*(SQR(a)+SQR(b)))
{
LD A=1.0,B=-2.0*ant[j].y,C=Sqr(ant[j].y)+Sqr(Ni+ant[j].x)-0.25;
LD X1=(-B-sqrt(Sqr(B)-4.0*A*C))/(2.0*A),X2=(-B+sqrt(Sqr(B)-4.0*A*C))/(2.0*A);
if((l-eps<=X1&&r+eps>=X1)||(l-eps<=X2&&r+eps>=X2))ant[j].HP-=d;
}
}
}
else
{
int temp=target;
int dis=0x7fffffff;
for(int j=;j<=ant_now;j++)
if(SQR(ant[j].x-tor[i].x)+SQR(ant[j].y-tor[i].y)<dis)
target=j,dis=SQR(ant[j].x-tor[i].x)+SQR(ant[j].y-tor[i].y);
if(SQR(ant[target].x-tor[i].x)+SQR(ant[target].y-tor[i].y)<=SQR(r))
{
int a=ant[target].y-tor[i].y,b=tor[i].x-ant[target].x,c=tor[i].y*(ant[target].x-tor[i].x)+tor[i].x*(tor[i].y-ant[target].y);
if(b!=)
{
LD Ki=0.0-(LD)a/b,Bi=0.0-(LD)c/b;
int l=ant[target].x<tor[i].x?ant[target].x:tor[i].x,r=ant[target].x>tor[i].x?ant[target].x:tor[i].x;
for(int j=;j<=ant_now;j++)
if(SQR(a*ant[j].x+b*ant[j].y+c)<=0.25*(SQR(a)+SQR(b)))
{
LD A=(1.0+Sqr(Ki)),B=2.0*Ki*(Bi-ant[j].y)-2.0*ant[j].x,C=Sqr(Bi-ant[j].y)+Sqr(ant[j].x)-0.25;
LD X1=(-B-sqrt(Sqr(B)-4.0*A*C))/(2.0*A),X2=(-B+sqrt(Sqr(B)-4.0*A*C))/(2.0*A);
if((l-eps<=X1&&r+eps>=X1)||(l-eps<=X2&&r+eps>=X2))ant[j].HP-=d;
}
}
else
{
LD Ni=(LD)c/a;
int l=ant[target].y<tor[i].y?ant[target].y:tor[i].y,r=ant[target].y>tor[i].y?ant[target].y:tor[i].y;
for(int j=;j<=ant_now;j++)
if(SQR(a*ant[j].x+b*ant[j].y+c)<=0.25*(SQR(a)+SQR(b)))
{
LD A=1.0,B=-2.0*ant[j].y,C=Sqr(ant[j].y)+Sqr(Ni+ant[j].x)-0.25;
LD X1=(-B-sqrt(Sqr(B)-4.0*A*C))/(2.0*A),X2=(-B+sqrt(Sqr(B)-4.0*A*C))/(2.0*A);
if((l-eps<=X1&&r+eps>=X1)||(l-eps<=X2&&r+eps>=X2))ant[j].HP-=d;
}
}
}
target=temp;
}
}
else
{
for(int i=;i<=s;i++)
{
int dis=0x7fffffff;
for(int j=;j<=ant_now;j++)
if(SQR(ant[j].x-tor[i].x)+SQR(ant[j].y-tor[i].y)<dis)
target=j,dis=SQR(ant[j].x-tor[i].x)+SQR(ant[j].y-tor[i].y);
if(SQR(ant[target].x-tor[i].x)+SQR(ant[target].y-tor[i].y)<=SQR(r))
{
int a=ant[target].y-tor[i].y,b=tor[i].x-ant[target].x,c=tor[i].y*(ant[target].x-tor[i].x)+tor[i].x*(tor[i].y-ant[target].y);
if(b!=)
{
LD Ki=0.0-(LD)a/b,Bi=0.0-(LD)c/b;
int l=ant[target].x<tor[i].x?ant[target].x:tor[i].x,r=ant[target].x>tor[i].x?ant[target].x:tor[i].x;
for(int j=;j<=ant_now;j++)
if(SQR(a*ant[j].x+b*ant[j].y+c)<=0.25*(SQR(a)+SQR(b)))
{
LD A=(1.0+Sqr(Ki)),B=2.0*Ki*(Bi-ant[j].y)-2.0*ant[j].x,C=Sqr(Bi-ant[j].y)+Sqr(ant[j].x)-0.25;
LD X1=(-B-sqrt(Sqr(B)-4.0*A*C))/(2.0*A),X2=(-B+sqrt(Sqr(B)-4.0*A*C))/(2.0*A);
if((l-eps<=X1&&r+eps>=X1)||(l-eps<=X2&&r+eps>=X2))ant[j].HP-=d;
}
}
else
{
LD Ni=(LD)c/a;
int l=ant[target].y<tor[i].y?ant[target].y:tor[i].y,r=ant[target].y>tor[i].y?ant[target].y:tor[i].y;
for(int j=;j<=ant_now;j++)
if(SQR(a*ant[j].x+b*ant[j].y+c)<=0.25*(SQR(a)+SQR(b)))
{
LD A=1.0,B=-2.0*ant[j].y,C=Sqr(ant[j].y)+Sqr(Ni+ant[j].x)-0.25;
LD X1=(-B-sqrt(Sqr(B)-4.0*A*C))/(2.0*A),X2=(-B+sqrt(Sqr(B)-4.0*A*C))/(2.0*A);
if((l-eps<=X1&&r+eps>=X1)||(l-eps<=X2&&r+eps>=X2))ant[j].HP-=d;
}
}
}
target=;
}
}
bool god=;
int temp=ant_now;
ant_now=;
for(int i=;i<=temp;i++)
if(ant[i].HP<)
{
if(i==target) target=;
pos[ant[i].x][ant[i].y]=;
}
else
{
if(i==target)
{
if(ant[i].x==&&ant[i].y==) god=;
target=ant_now+;
}
ant[++ant_now]=ant[i];
}
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
if(Information[i][j])--Information[i][j];
if(god)
{
printf("Game over after %d seconds\n",t);
printf("%d\n",ant_now);
for(int i=;i<=ant_now;i++)
printf("%d %d %d %d %d\n",ant[i].old,ant[i].id,ant[i].HP,ant[i].x,ant[i].y);
return ;
}
for(int i=;i<=ant_now;i++)++ant[i].old;
}
printf("The game is going on\n");
printf("%d\n",ant_now);
for(int i=;i<=ant_now;i++)
printf("%d %d %d %d %d\n",ant[i].old,ant[i].id,ant[i].HP,ant[i].x,ant[i].y);
return ;
}
[bzoj1033] [ZJOI2008]杀蚂蚁 Big MoNI的更多相关文章
- bzoj千题计划121:bzoj1033: [ZJOI2008]杀蚂蚁antbuster
http://www.lydsy.com/JudgeOnline/problem.php?id=1033 经半个下午+一个晚上+半个晚上 的 昏天黑地调代码 最终成果: codevs.洛谷.tyvj上 ...
- BZOJ1033:[ZJOI2008]杀蚂蚁antbuster(模拟)
Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右 下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的 ...
- [bzoj1033] [ZJOI2008]杀蚂蚁antbuster
Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的任 ...
- Luogu2586 [ZJOI2008]杀蚂蚁 ---- 模拟
Luogu2586 [ZJOI2008]杀蚂蚁 题意 还是一道大模拟 https://www.luogu.org/problemnew/show/P2586 大概就是炮塔大蚂蚁的故事 下载这个游戏ht ...
- [BZOJ 1033][ZJOI2008]杀蚂蚁antbuster
1033: [ZJOI2008]杀蚂蚁antbuster Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1200 Solved: 507[Submi ...
- [ZJOI2008]杀蚂蚁antbuster
[ZJOI2008]杀蚂蚁antbuster 题目 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试 ...
- P2586 [ZJOI2008]杀蚂蚁(模拟)
P2586 [ZJOI2008]杀蚂蚁 大模拟. 什么都不想补了. 看变量名感性理解吧 #include<iostream> #include<cstdio> #include ...
- BZOJ1033:[ZJOI2008]杀蚂蚁
我对模拟的理解:https://www.cnblogs.com/AKMer/p/9064018.html 题目传送门:https://www.lydsy.com/JudgeOnline/problem ...
- 【BZOJ 1033】 [ZJOI2008]杀蚂蚁antbuster
Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的任 ...
随机推荐
- YII2.0 获取当前访问地址/IP信息
假设我们当前页面的访问地址是:http://localhost/CMS/public/index.php?r=news&id=1 一. 1.获取当前域名:echo Yii::app()-> ...
- 转自 阿里云技术文档的 centos + PHP 环境 搭建
产品亮点 1.基于阿里云CentOS7.2镜像 2.采用yum方式安装,软件安装均为默认目录,未作任何修改. 3.采用经典LAMP组合,拓展性强,资源丰富,解决方案较多 4.附带PhpMyadmin和 ...
- 仿制用友U8界面
unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System ...
- SapScript
* [OPEN_FORM] SAPscript: フォーム印刷の開始 * [START_FORM] SAPscript: 書式を開始 * [WRITE_FORM] SAPscript: 書式ウィンドウ ...
- EF使用报错说缺少引用
在程序中已经引用了EF,也引用了System.Data,但是一起报这个错误: 在类前面也已经写了 using System.Data.Entity,百思不得其解,最后才发 ...
- error LNK2001: unresolved external symbol "public: __thiscall ControllerInterface::ControllerInterface(class QObject *)" (??0ControllerInterface@@QAE@PAVQObject@@@Z) downloadcontroller.obj
前几天刚遇到这个问题,但是今天再碰到就又要思考怎么解决.这次特别记录一下,以防下次碰到再手足无措: 1.看到这个报错第一感觉LNK关键字,表示连接错误,这种错误有几个可以下手的点 1)函数声明和定义是 ...
- 各种网站,app的手机号绑定真坑爹
各种网站,app的手机号绑定真坑爹,无力吐槽,哎
- Qt Qwdget 汽车仪表知识点拆解5 标题栏图标闪烁
先贴上效果图,注意,没有写逻辑,都是乱动的 看下最上面的部分,有一些仪表图标在闪烁,如果一个一个写,也是可以实现的,不过感觉要累死的节奏 这里我写了一个我自己的Label,完了把把这些QLabel提升 ...
- (干货分享)mac python+appium环境搭建
因为mac本自带python2.x(不建议卸载,因为本本本身有很多依赖与此),所以装python3的过程极其坎坷,勉强装好后也总是各种报错.这次装appium环境,直接把原来的python3卸了,用h ...
- 开发react的一些记录
1.keyboard事件返回的对象SyntheticKeyboardEvent全部是null 解决方法:SyntheticKeyboardEvent的type,which,timeStamp可以得到你 ...