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 这两天做的又一道大模拟题,感觉这玩意有毒,会上瘾啊…… 比起猪国杀这道题真心不知道高到哪 ...
随机推荐
- iOS开发UITableView基本使用方法总结 分类: ios技术 2015-04-03 17:51 68人阅读 评论(0) 收藏
本文为大家呈现了iOS开发中UITableView基本使用方法总结.首先,Controller需要实现两个delegate ,分别是UITableViewDelegate 和UITableViewDa ...
- java实现——005从尾到头打印链表
import java.util.Stack; public class T005 { public static void main(String[] args){ Node n1 = new No ...
- C语言-for循环
for循环是C语言中的循环语句之一,它的一般形式为for(初值,条件表达式,步长){语句};初值通常是一个赋值语句, 它用来给循环控制变量赋初值: 条件表达式是一个关系表达式, 它决定什么时候退出循环 ...
- Java Spring MVC项目搭建(三)——“Hello World”
在Spring 的配置文件里,我们定义了一个bean ,Spring 会在启动时候会生成对象. <bean id = "helloworld" class="com ...
- 阿里云安装wordpress遇到的问题
在阿里云服务器上安装Nginx,php5.3.3环境,使用阿里云的RDS数据库 1,安装wordpress,提示您的PHP似乎没有安装运行WordPress所必需的MySQL扩展 解决方案:移除已经安 ...
- ios framework 开发 之 实战 一,合并失败了
保证public 文件目录独立 在 XCode 7 中,这一条已经自动实现了 Build Settings>Public Headers Folder Path "$(PROJECT_ ...
- JDBC oracle 错误总结
ORA-28040: No matching authentication protocol jdk:1.8 oracle:12c 使用ojdbc14.jar 报错:ORA-28040: No mat ...
- 连锁不平衡LD
http://wenku.baidu.com/link?url=Fr_C7J5F4KusZTpZJUfuVfh4Bpyb9BAY7IQhWAOYirQJW0Oz-X3fI5r41aPHiQR8ENn9 ...
- leetcode[149]Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. ...
- bmp图片显示
文件IO项目: 在开发板屏幕上循环显示目录里的图片 a.按照一定的间隔循环显示目录里的bmp图片 b.实现手指滑动来显示目录里的图片(bmp,jpg)上一张,下一张 d1: 1.能操控屏幕(查询开发板 ...