坑爹的模拟题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;
}