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 这两天做的又一道大模拟题,感觉这玩意有毒,会上瘾啊…… 比起猪国杀这道题真心不知道高到哪 ...
随机推荐
- WCF不用证书实现验证(messageheader)
上文WCF进阶:将消息正文Base64编码中介绍了实现自定义MessageInspector来记录消息和实现自定义Formatter来改写消息,本文介绍一下在WCF中使用SoapHeader进行验证的 ...
- Apache Bench安装与使用
一.Apache Bench简介 ApacheBench 是 Apache 服务器自带的一个web压力测试工具,简称ab.ab又是一个命令行工具,对发起负载的本机要求很低,根据ab命令可以创建很多的并 ...
- 使用React Native来撰写跨平台的App
React Native 是一个 JavaScript 的框架,用来撰写实时的.可原生呈现 iOS 和 Android 的应用.其是基于 React的,而 React 是 Facebook 的用于构建 ...
- EntityFrameWork分页
EF分页代码 using System; using System.Collections.Generic; using System.Linq; using System.Web; using Sy ...
- Eclipse配置Git发布项目到Github
很牛叉的博客http://blog.csdn.net/luckarecs/article/details/7427605 一.安装插件 菜单栏Help --> Install New Softw ...
- iOS 之 系统机制
iOS 沙盒 iOS 8 之 新特性 iOS 操作系统整体架构层次讲解
- Android应用性能优化方案
1.避免创建不必要的对象 2.如果方法用不到成员变量,可以把方法声明为静态(static),这样性能会提高百分之十五到百分之二十 3.避免使用get/set存取字段,可以把字段声明为public直接访 ...
- 在Delphi中隐藏程序进程
在开发某些软件的时候,为了保护程序自身,就需要用到隐藏程序进程.以下通过实例来讲解隐藏程序进程的方法: 1.创建一个新的项目 Project1 选择File,New Application.在表单Fo ...
- LNAMP 中的PHP探针
<?php /* ----------------本探针基于YaHei.net探针------------------- */ error_reporting(0); //抑制所有错误信息 @h ...
- Android4.0新增的网格布局
网格布局由GridLayout代表,它是Android 4.0新增的布局管理器,因此需要在Android 4.0 之后的版本中才能使用该布局管理器.如果希望在更早的Android平台上使用该布局管理器 ...