BZOJ 1033: [ZJOI2008]杀蚂蚁antbuster(模拟)
坑爹的模拟题QAQ DEBUG多了1kb QAQ
按题意做就行了
注意理解题意啊啊啊啊
尼玛输出忘换行wa了3次QAQ
CODE:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
struct node{
int x,y,lx,ly;
bool flag,alive;
int age;
int hp;
double mx;
int level;
}ant[8];
#define maxn 200100
double hp[maxn+10];
int map[20][20];//信息素
bool bo[20][20];
int p[30][2];
int w[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int dist(int x1,int y1,int x2,int y2){
return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
double xa(int x1,int y1,int x2,int y2){
return x1*y2-x2*y1;
}
bool cross(int x1,int y1,int x2,int y2,int x3,int y3){
double d=sqrt(dist(x1,y1,x2,y2));
if (x1==x3&&y1==y3) return 1;
if (x2==x3&&y2==y3) return 1;
int mxx=max(x1,x2),mxy=max(y1,y2),mnx=min(x1,x2),mny=min(y1,y2);
if (mxx<x3||mxy<y3||mnx>x3||mny>y3) return 0;
if (fabs(xa(x1-x3,y1-y3,x2-x3,y2-y3))/d<=0.5) return 1;
return 0;
}
int init(){
hp[0]=4;
for (int i=1;i<=maxn;i++)
if (i%6==1) hp[i]=1.1*hp[i-1];
else hp[i]=hp[i-1];
}
int sum=0;
int born(int x){
if (bo[0][0]) return 0;
sum++;
ant[x]=(node){0,0,0,0,0,1,0,hp[sum],hp[sum],(sum-1)/6+1};
bo[0][0]=1;
return 0;
}
bool cmp(node x,node y){
if (x.alive&&y.alive) return x.age>y.age;
return x.alive>y.alive;
}
int n,m;
bool iscake=1;
int move(int x){
for (int t=1;t<=6&&ant[t].alive;t++) map[ant[t].x][ant[t].y]+=ant[t].flag?5:2;
for (int t=1;t<=6&&ant[t].alive;t++){
bool b=0;
for (int i=0;i<4;i++){
int nowx=ant[t].x+w[i][0],nowy=ant[t].y+w[i][1];
if (nowx>=0&&nowx<=n&&nowy>=0&&nowy<=m&&!bo[nowx][nowy]&&(nowx!=ant[t].lx||nowy!=ant[t].ly)) b=1;
}
if (!b) {
ant[t].lx=ant[t].x;ant[t].ly=ant[t].y;continue;
}
bo[ant[t].x][ant[t].y]=0;
int mx=-0x7fffffff;
for (int i=0;i<4;i++){
int nowx=ant[t].x+w[i][0],nowy=ant[t].y+w[i][1];
if (nowx>=0&&nowx<=n&&nowy>=0&&nowy<=m&&!bo[nowx][nowy]&&(nowx!=ant[t].lx||nowy!=ant[t].ly))
mx=max(mx,map[nowx][nowy]);
}
for (int i=0;i<4;i++){
int nowx=ant[t].x+w[i][0],nowy=ant[t].y+w[i][1];
if (nowx>=0&&nowx<=n&&nowy>=0&&nowy<=m&&!bo[nowx][nowy]&&map[nowx][nowy]==mx&&(nowy!=ant[t].ly||nowx!=ant[t].lx)) {
if ((ant[t].age+1)%5!=0) {
swap(ant[t].x,ant[t].lx);
swap(ant[t].y,ant[t].ly);
ant[t].x=nowx;
ant[t].y=nowy;
}else for (int j=(i-1+4)%4;;j=(j-1+4)%4){
int nowx=ant[t].x+w[j][0],nowy=ant[t].y+w[j][1];
if (nowx>=0&&nowx<=n&&nowy>=0&&nowy<=m&&!bo[nowx][nowy]&&(nowy!=ant[t].ly||nowx!=ant[t].lx)) {
swap(ant[t].x,ant[t].lx);
swap(ant[t].y,ant[t].ly);
ant[t].x=nowx;
ant[t].y=nowy;
break;
}
}
break;
}
}
bo[ant[t].x][ant[t].y]=1;
}
for (int t=1;t<=6&&ant[t].alive;t++)
if (ant[t].x==n&&ant[t].y==m&&iscake){
iscake=0;ant[t].flag=1;ant[t].hp=min(ant[t].hp+(int) (ant[t].mx)/2, (int) ant[t].mx);
}
return 0;
}
int r,d;
int attack(int x){
int target=0;
for (int t=1;t<=6&&ant[t].alive;t++)
if (ant[t].flag&&dist(p[x][0],p[x][1],ant[t].x,ant[t].y)<=r*r) target=t;
if (!target)
for (int t=1;t<=6&&ant[t].alive;t++)
if ((!target&&dist(p[x][0],p[x][1],ant[t].x,ant[t].y)<=r*r)||
(target&&dist(p[x][0],p[x][1],ant[t].x,ant[t].y)<dist(p[x][0],p[x][1],ant[target].x,ant[target].y))) target=t;
if (!target) return 0;
for (int t=1;t<=6&&ant[t].alive;t++)
if (cross(p[x][0],p[x][1],ant[target].x,ant[target].y,ant[t].x,ant[t].y)) ant[t].hp-=d;
return 0;
}
bool check(){
for (int t=1;t<=6&&ant[t].alive;t++){
if (ant[t].hp<0) {
ant[t].alive=0;
bo[ant[t].x][ant[t].y]=0;
if (ant[t].flag) iscake=1;
}
}
for (int t=1;t<=6;t++) {
if (!ant[t].alive) continue;
if (ant[t].flag&&ant[t].x==0&&ant[t].y==0) return 1;
}
return 0;
}
int ending(){
for(int i=0;i<=n;i++)
for (int j=0;j<=m;j++)
map[i][j]=max(0,map[i][j]-1);
for (int i=1;i<=6;i++) ant[i].age++;
return 0;
}
int s;
int solve(int x){
for (int i=1;i<=6;i++)
if (!ant[i].alive) {born(i);break;}
sort(ant+1,ant+7,cmp);
move(x);
for (int i=1;i<=s;i++) attack(i);
if (check())return 1;
ending();
return 0;
}
int endprint(){
sort(ant+1,ant+7,cmp);
int sum;
for (sum=1;sum<=6&&ant[sum].alive;sum++);
printf("%d\n",sum-1);
for (int i=1;i<=6&&ant[i].alive;i++) printf("%d %d %d %d %d\n",ant[i].age,ant[i].level,ant[i].hp,ant[i].x,ant[i].y);
return 0;
}
int main(){
init();
scanf("%d%d",&n,&m);
scanf("%d%d%d",&s,&d,&r);
for (int i=1;i<=s;i++) {
scanf("%d%d",&p[i][0],&p[i][1]);
bo[p[i][0]][p[i][1]]=1;
}
int T;bool b=1;
scanf("%d",&T);
for (int i=1;i<=T;i++){
if (solve(i)) {
printf("Game over after %d seconds\n",i);
b=0;
break;
}
}
if (b) printf("The game is going on\n");
endprint();
return 0;
}
BZOJ 1033: [ZJOI2008]杀蚂蚁antbuster(模拟)的更多相关文章
- [BZOJ 1033][ZJOI2008]杀蚂蚁antbuster
1033: [ZJOI2008]杀蚂蚁antbuster Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1200 Solved: 507[Submi ...
- [BZOJ 1033] [ZJOI2008] 杀蚂蚁antbuster 【模拟!】
题目链接: BZOJ - 1033 题目分析 模拟!纯粹按照题目描述模拟! 这是一道喜闻乐见的经典模拟题! 我一共写了2遍,Debug 历时2天的所有晚自习 ... 时间超过 8h ... 我真是太弱 ...
- BZOJ1033:[ZJOI2008]杀蚂蚁antbuster(模拟)
Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右 下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的 ...
- [ZJOI2008]杀蚂蚁antbuster
[ZJOI2008]杀蚂蚁antbuster 题目 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试 ...
- P2586 [ZJOI2008]杀蚂蚁(模拟)
P2586 [ZJOI2008]杀蚂蚁 大模拟. 什么都不想补了. 看变量名感性理解吧 #include<iostream> #include<cstdio> #include ...
- 【BZOJ 1033】 [ZJOI2008]杀蚂蚁antbuster
Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的任 ...
- bzoj千题计划121:bzoj1033: [ZJOI2008]杀蚂蚁antbuster
http://www.lydsy.com/JudgeOnline/problem.php?id=1033 经半个下午+一个晚上+半个晚上 的 昏天黑地调代码 最终成果: codevs.洛谷.tyvj上 ...
- [bzoj1033] [ZJOI2008]杀蚂蚁antbuster
Description 最近,佳佳迷上了一款好玩的小游戏:antbuster.游戏规则非常简单:在一张地图上,左上角是蚂蚁窝,右下角是蛋糕,蚂蚁会源源不断地从窝里爬出来,试图把蛋糕搬回蚂蚁窝.而你的任 ...
- [ZJOI2008]杀蚂蚁antbuster 题解
一个题目的可读版本:https://www.zybuluo.com/Jerusalem/note/221811 这两天做的又一道大模拟题,感觉这玩意有毒,会上瘾啊…… 比起猪国杀这道题真心不知道高到哪 ...
随机推荐
- UVa 900 - Brick Wall Patterns
题目大意:用1*2的砖头建n*2的墙,问有多少种不同的砖头排列方式?与斐波那契序列相似. #include <cstdio> #define MAXN 60 #define N 50 un ...
- [noip2013]货车运输(kruskal + 树上倍增)
描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路.每一条道路对车辆都有重量限制,简称限重.现在有 q 辆货车在运输货物,司机们想知道每辆车在不超过车辆限重的情况下,最多能运多 ...
- listview 去掉header和footer中的分割线
在listView中加上android:headerDividersEnabled="false" android:footerDividersEnabled="fals ...
- MongoDB升级教程
1.排序 sort()方法:其中 1 为升序排列,而-1是用于降序排列. db.col.find({},{"title":1,_id:0}).sort({"likes&q ...
- runat="server"
加runat="server"表示该控件是服务器端控件,不加表示是客户端控件. runat="server"直接回交服务器,处理数据,又以数据加密后的hidde ...
- python 发起HTTP请求
因为微信公众号群发需要调用高级群发接口,其中涉及到python发起HTTP请求,现在将相关实现操作记录如下: 首先,HTTP请求分为GET和POST,如下所示: 首先是发起get 请求: # -*- ...
- zabbix3.0.4 部署History
[root@zabbix-Test ~]# history 1 passwd root 2 exit 3 yum install ntpd* 4 yum inst ...
- matlab计算矩阵每列非0元素个数
在统计分析中,有时候需要计算矩阵每列非0元素的个数,可以用以下方法: 先用find找到每列不为0的元素index,然后用count计数. 假设有矩阵A[M,N], 结果存在countZeros cou ...
- 建立、配置和使用Activity——使用Bundle在Activity之间交换数据
当一个Activity启动另一个Activity时,常常会有一些数据需要传过去——这就像Web应用从一个Servlet跳到另一个Serlvet时,Web应用习惯把需要交换的数据放入requestSco ...
- php生成PDF文件(FPDF)
首先要下载FPDF http://www.fpdf.org/ 附件可以在我的资源里下载http://yunpan.cn/c3RJ5BpPfX6dL 访问密码 f1f2 FPDF文档:http:// ...