[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.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的任 ...
随机推荐
- Hive初识(一)
LOAD DATA语句 一般来说,在SQL创建表后,我们就可以使用INSERT语句插入数据.但在Hive中,可以使用LOAD DATA语句来插入数据. LOAD DATA [LOCAL] INPATH ...
- Python基于jieba的中文词云
今日学习了python的词云技术 from os import path from wordcloud import WordCloud import matplotlib.pyplot as plt ...
- PyCharm使用秘籍视频
PyCharm使用视频上传至企鹅群公告 需要自行添加群获取
- 【python3.X】python练习笔记[1]
##三位数水仙花 ##方法一,小于指定数字的水仙花数 x=eval(input()) a,b,c = 0,0,0 for i in range (100,x,1): a=i%10 b=i//100 c ...
- crm踩坑记(一)
目录 antd es6 Object.entries() Object.keys() Object.getOwnPropertyNames() 很神奇的用法!!! eslint 傻逼 其他 参考 an ...
- 3.Linux 文件的压缩与打包
1.常用压缩打包命令 常用的压缩打包扩展名为如下: *.Z compress 程序压缩的文件,非常老旧了,不再细说 *.gz gzip 程序压缩的文件: *.bz2 bzip2 程序压缩的文件: *. ...
- 第三十五篇 类的内置属性(attr属性),包装和授权,__getattr__
双下划线开头的attr方法,都是类内置的方法. 一. 如果没有在类里定义这三个方法,调用的时候就调用类内置的默认的方法 class Too: pass # 类没有定义这三个属性,就用系统默认的方法 t ...
- cocos2d-x 动作类
动作类是Action IntervalAction是间隔动作,InstantAction是瞬时动作. 动作的管理是要由节点负责的,任何的节点都可以管理节点,如精灵.菜单.层.甚至场景都可以管理动作.节 ...
- cocos2d-x的坐标和节点层级
- ThreadPool线程池的几种姿势比较
from multiprocessing.pool import ThreadPool #from multiprocessing.dummy import Pool as ThreadPool #这 ...