Cleared everything
parent
dea2c5750f
commit
095824b390
535
0_6_1.cpp
535
0_6_1.cpp
|
@ -1,535 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#include<queue>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[15][15];
|
||||
int minimap[4][15][15];
|
||||
int now[4],tot[4],area[4];
|
||||
int m,n,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
int edge_color[15][15][15][15];
|
||||
int timeleft[200];
|
||||
int mode=mode_start;
|
||||
unsigned int relative_distance[4][15][15][15][15];
|
||||
class dot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
dot* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
dot* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new dot;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new dot;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=2;k<=num;k++)
|
||||
{
|
||||
if(road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if(road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if(road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if(j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if(road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if(j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if(road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if(i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if(road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if(i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(top&&bottom&&left&&right)
|
||||
{
|
||||
if(-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if(state_die==state)
|
||||
{
|
||||
if(ID_0==ID) {player0->die();if(player0->road[1]->x==x&&player0->road[1]->y==y){player0->insert(x,y);player0->paint();player0->clear();}}
|
||||
if(ID_1==ID) {player1->die();if(player1->road[1]->x==x&&player1->road[1]->y==y){player1->insert(x,y);player1->paint();player1->clear();}}
|
||||
if(ID_2==ID) {player2->die();if(player2->road[1]->x==x&&player2->road[1]->y==y){player2->insert(x,y);player2->paint();player2->clear();}}
|
||||
if(ID_3==ID) {player3->die();if(player3->road[1]->x==x&&player3->road[1]->y==y){player3->insert(x,y);player3->paint();player3->clear();}}
|
||||
}
|
||||
if(state_up==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
if(state_down==player0->state) player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->up();
|
||||
player0->clear();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
if(state_down==player1->state) player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->up();
|
||||
player1->clear();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
if(state_down==player2->state) player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->up();
|
||||
player2->clear();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
if(state_down==player3->state) player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->up();
|
||||
player3->clear();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(state_down==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
player0->down();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
player1->down();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
player2->down();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
player3->down();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(ID_0==ID) player0->change(x,y);
|
||||
if(ID_1==ID) player1->change(x,y);
|
||||
if(ID_2==ID) player2->change(x,y);
|
||||
if(ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
int i,j,k;
|
||||
for(i=0;i<=3;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
if(1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for(int s=0;s<=3;s++)
|
||||
if(tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if(-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
player0->score=player0->score+area[0]*area[0]*10;
|
||||
player1->score=player1->score+area[1]*area[1]*10;
|
||||
player2->score=player2->score+area[2]*area[2]*10;
|
||||
player3->score=player3->score+area[3]*area[3]*10;
|
||||
for(i=0;i<=3;i++)
|
||||
if(0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
dot bind[200];
|
||||
enclosure* game;
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
ofstream fout4(".\\output4.txt");
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int update_distance(dot* start_point,int ID)
|
||||
{
|
||||
//Todo:
|
||||
//1. Get unpassable lines
|
||||
//2. Do a bfs
|
||||
//Note:
|
||||
//1. An edge label 400 means specially defined unpassable lines
|
||||
//2. This update process is only valid for a certain ID, i.e. the defined player
|
||||
unsigned int tmp_distance[15][15];
|
||||
bool in_queue[15][15];
|
||||
memset(tmp_distance,0xff,sizeof(tmp_distance));
|
||||
memset(in_queue,0,sizeof(in_queue));
|
||||
queue<dot*>* q=new queue<dot*>;
|
||||
q->push(start_point);
|
||||
tmp_distance[start_point->x][start_point->y]=0;
|
||||
while((!q->empty()))
|
||||
{
|
||||
dot* tmp=q->front();
|
||||
q->pop();
|
||||
in_queue[tmp->x][tmp->y]=false;
|
||||
if((tmp->x>0)&&(edge_color[tmp->x][tmp->y][tmp->x-1][tmp->y]==-1)&&(tmp_distance[tmp->x-1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x-1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x-1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x-1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x-1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->x<10)&&(edge_color[tmp->x][tmp->y][tmp->x+1][tmp->y]==-1)&&(tmp_distance[tmp->x+1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x+1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x+1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x+1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x+1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y>0)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y-1]==-1)&&(tmp_distance[tmp->x][tmp->y-1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y-1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y-1;
|
||||
if(!in_queue[tmp->x][tmp->y-1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y-1]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y<10)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y+1]==-1)&&(tmp_distance[tmp->x][tmp->y+1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y+1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y+1;
|
||||
if(!in_queue[tmp->x][tmp->y+1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y+1]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=10;i++) for(int j=0;j<=10;j++) relative_distance[ID][start_point->x][start_point->y][i][j]=tmp_distance[i][j];
|
||||
return -1;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
update_distance(game->player0->position,0);
|
||||
update_distance(game->player1->position,1);
|
||||
update_distance(game->player2->position,2);
|
||||
update_distance(game->player3->position,3);
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//Output Area
|
||||
if(mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
//Debug Output
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j+1][i];
|
||||
fout3<<endl;
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
fout4<<"---RELATIVE DISTANCE---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
int rd=relative_distance[now_id][now_x][now_y][j][i];
|
||||
fout4<<setiosflags(ios::fixed)<<setw(4)<<rd;
|
||||
}
|
||||
fout4<<endl;
|
||||
}
|
||||
fout4<<"----------END----------"<<endl;
|
||||
fout4<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for(int i=0;i<4;i++) now[i]=100*i;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
memset(relative_distance,0xff,sizeof(relative_distance));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for(int i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if(!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int total;
|
||||
cin>>total;
|
||||
for(int i=1;i<=total;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
This repository is cleared because it's no longer support by its owner.
|
BIN
enclosure.exe
BIN
enclosure.exe
Binary file not shown.
BIN
log.tar.gz
BIN
log.tar.gz
Binary file not shown.
41
log0.in
41
log0.in
|
@ -1,41 +0,0 @@
|
|||
[START] 0
|
||||
[STATUS] 10 0 0 0 0 5 5 0 0 0 5 5 0 0 0 5 5 0 0 0 0
|
||||
[STATUS] 10 1 1 0 0 5 5 0 4 0 4 5 0 0 -10 5 5 0 4 0 2 5 4 2 5 6 2
|
||||
[STATUS] 10 2 1 0 0 5 5 0 3 0 5 5 0 0 -20 5 5 0 3 0 5 5 4 1 5 6 1 4 5 2 4 4 2 4 6 2
|
||||
[STATUS] 10 3 1 0 0 5 5 0 4 0 4 5 0 4 -30 5 5 0 4 0 4 5 4 2 5 6 2 4 4 1 4 6 1
|
||||
[STATUS] 10 4 1 0 0 5 5 0 3 0 4 5 0 3 -30 5 5 0 3 0 2 5 4 1 5 6 1
|
||||
[STATUS] 10 5 1 0 0 5 5 0 2 0 4 5 0 2 -30 5 5 0 2 0 0
|
||||
[STATUS] 10 6 1 0 0 5 5 0 1 0 4 5 0 1 -30 5 5 0 1 0 0
|
||||
[STATUS] 10 7 1 0 0 5 5 0 0 0 4 5 0 0 -30 5 5 0 0 0 0
|
||||
[STATUS] 10 8 1 0 0 6 5 0 0 0 4 4 0 0 -30 5 4 0 0 0 0
|
||||
[STATUS] 10 9 1 0 0 5 5 0 0 0 5 4 0 0 -30 6 4 0 0 0 0
|
||||
[STATUS] 10 10 1 0 0 5 5 0 0 0 5 4 0 0 -30 6 5 0 0 0 0
|
||||
[STATUS] 9 10 1 0 0 5 5 0 0 0 4 4 0 0 -30 6 6 0 0 0 0
|
||||
[STATUS] 8 10 1 0 0 5 6 0 0 0 5 4 0 0 -30 6 7 0 0 0 0
|
||||
[STATUS] 7 10 1 0 0 5 5 0 0 0 4 4 0 0 -30 6 6 0 0 0 0
|
||||
[STATUS] 6 10 1 0 0 5 6 0 0 0 3 4 0 0 -30 6 6 0 0 0 0
|
||||
[STATUS] 5 10 1 0 0 5 5 0 0 0 3 4 0 0 -30 6 5 0 0 0 0
|
||||
[STATUS] 4 10 1 0 0 6 5 1 0 0 4 4 1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 3 10 1 0 0 7 5 1 0 0 5 4 1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 2 10 1 0 0 7 4 1 0 0 5 3 1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 1 10 1 0 0 7 3 1 0 0 5 2 1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 10 1 0 0 6 3 1 0 0 4 2 1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 9 1 0 0 5 3 1 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 8 1 0 0 5 4 1 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 7 1 0 0 5 5 0 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 6 1 0 0 5 5 0 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 5 1 0 0 4 5 0 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 4 1 0 0 4 6 0 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 3 1 0 0 4 5 0 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 2 1 0 0 3 5 0 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 1 1 0 0 3 4 0 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 0 0 1 0 0 3 4 0 0 0 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 1 0 1 0 0 4 4 0 0 -10 3 2 -1 0 -30 7 5 -1 0 0 3 3 4 2 3 3 2 3 5 2
|
||||
[STATUS] 2 0 1 0 0 4 4 0 0 -10 3 2 -1 0 -30 7 5 -1 0 0 3 3 4 1 3 3 1 3 5 1
|
||||
[STATUS] 3 0 1 0 0 4 3 0 0 -20 3 2 -1 0 -30 7 5 -1 0 0 3 3 4 2 4 4 2 5 4 2
|
||||
[STATUS] 4 0 1 0 0 3 3 0 0 -20 3 2 -1 0 -30 7 5 -1 0 0 3 3 4 1 4 4 1 5 4 1
|
||||
[STATUS] 5 0 1 0 0 3 4 0 4 -20 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 6 0 1 0 0 3 4 0 3 -20 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 7 0 1 0 0 3 4 0 2 -20 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 8 0 1 0 0 3 4 0 1 -20 3 2 -1 0 -30 7 5 -1 0 0 0
|
||||
[STATUS] 9 0 1 0 0 3 4 0 0 -20 3 2 -1 0 -30 7 5 -1 0 0 0
|
41
log0.out
41
log0.out
|
@ -1,41 +0,0 @@
|
|||
[POS] 10 0
|
||||
[ACTION] d 1
|
||||
[ACTION] d 0
|
||||
[ACTION] d 0
|
||||
[ACTION] d 0
|
||||
[ACTION] d 0
|
||||
[ACTION] d 0
|
||||
[ACTION] d 0
|
||||
[ACTION] d 0
|
||||
[ACTION] d 0
|
||||
[ACTION] d 0
|
||||
[ACTION] l 0
|
||||
[ACTION] l 0
|
||||
[ACTION] l 0
|
||||
[ACTION] l 0
|
||||
[ACTION] l 0
|
||||
[ACTION] l 0
|
||||
[ACTION] l 0
|
||||
[ACTION] l 0
|
||||
[ACTION] l 0
|
||||
[ACTION] l 0
|
||||
[ACTION] u 0
|
||||
[ACTION] u 0
|
||||
[ACTION] u 0
|
||||
[ACTION] u 0
|
||||
[ACTION] u 0
|
||||
[ACTION] u 0
|
||||
[ACTION] u 0
|
||||
[ACTION] u 0
|
||||
[ACTION] u 0
|
||||
[ACTION] u 0
|
||||
[ACTION] r 0
|
||||
[ACTION] r 0
|
||||
[ACTION] r 0
|
||||
[ACTION] r 0
|
||||
[ACTION] r 0
|
||||
[ACTION] r 0
|
||||
[ACTION] r 0
|
||||
[ACTION] r 0
|
||||
[ACTION] r 0
|
||||
[ACTION] r 0
|
285
orz_0_0.cpp
285
orz_0_0.cpp
|
@ -1,285 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
//dqb area
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
//Soft Ginger area
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
//dqb area
|
||||
using namespace std;
|
||||
int map[20][20];
|
||||
class point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
point* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
point* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
int size=0;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (0==map[i][j])
|
||||
{
|
||||
map[i][j]=ID;
|
||||
size++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
score=score+size*size*10;
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID) player0->die();
|
||||
if (ID_1==ID) player1->die();
|
||||
if (ID_2==ID) player2->die();
|
||||
if (ID_3==ID) player3->die();
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID) {if (state_down==player0->state) player0->paint();player0->up();}
|
||||
if (ID_1==ID) {if (state_down==player1->state) player1->paint();player1->up();}
|
||||
if (ID_2==ID) {if (state_down==player2->state) player2->paint();player2->up();}
|
||||
if (ID_3==ID) {if (state_down==player3->state) player3->paint();player3->up();}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID) {player0->down();player0->insert(x,y);}
|
||||
if (ID_1==ID) {player1->down();player1->insert(x,y);}
|
||||
if (ID_2==ID) {player2->down();player2->insert(x,y);}
|
||||
if (ID_3==ID) {player3->down();player3->insert(x,y);}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
};
|
||||
//dqb area
|
||||
int m,n,i,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
point bind[200];
|
||||
int timeleft[200];
|
||||
enclosure* game;
|
||||
//Soft Ginger area
|
||||
int mode=mode_start;
|
||||
void brain()
|
||||
{
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//State Processing
|
||||
if(mode==mode_left&&now_y==0)
|
||||
{
|
||||
cout<<"[ACTION] r 1"<<endl;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
cout<<"[ACTION] r 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
cout<<"[ACTION] u 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
cout<<"[ACTION] l 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
cout<<"[ACTION] d 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
cout<<"[ACTION] s 0"<<endl;
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
cin>>label;
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
for (i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
continue;
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
int tot;
|
||||
cin>>tot;
|
||||
for (i=1;i<=tot;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[j].y>>timeleft[i];
|
||||
}
|
||||
//Soft Ginger area
|
||||
brain();
|
||||
//dqb area
|
||||
}
|
||||
}
|
291
orz_0_1.cpp
291
orz_0_1.cpp
|
@ -1,291 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
//dqb area
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
//Soft Ginger area
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
//dqb area
|
||||
using namespace std;
|
||||
int map[20][20];
|
||||
int now[4];
|
||||
class point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
point* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
point* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
int size=0;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (0==map[i][j])
|
||||
{
|
||||
map[i][j]=now[ID];
|
||||
now[ID]++;
|
||||
size++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
score=score+size*size*10;
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID) player0->die();
|
||||
if (ID_1==ID) player1->die();
|
||||
if (ID_2==ID) player2->die();
|
||||
if (ID_3==ID) player3->die();
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID) {if (state_down==player0->state) player0->paint();player0->up();}
|
||||
if (ID_1==ID) {if (state_down==player1->state) player1->paint();player1->up();}
|
||||
if (ID_2==ID) {if (state_down==player2->state) player2->paint();player2->up();}
|
||||
if (ID_3==ID) {if (state_down==player3->state) player3->paint();player3->up();}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID) {player0->down();player0->insert(x,y);}
|
||||
if (ID_1==ID) {player1->down();player1->insert(x,y);}
|
||||
if (ID_2==ID) {player2->down();player2->insert(x,y);}
|
||||
if (ID_3==ID) {player3->down();player3->insert(x,y);}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
};
|
||||
//dqb area
|
||||
int m,n,i,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
point bind[200];
|
||||
int timeleft[200];
|
||||
enclosure* game;
|
||||
//Soft Ginger area
|
||||
int mode=mode_start;
|
||||
void brain()
|
||||
{
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//State Processing
|
||||
if(mode==mode_left&&now_y==0)
|
||||
{
|
||||
cout<<"[ACTION] r 1"<<endl;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
cout<<"[ACTION] r 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
cout<<"[ACTION] u 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
cout<<"[ACTION] l 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
cout<<"[ACTION] d 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
cout<<"[ACTION] s 0"<<endl;
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
now[0]=0;
|
||||
now[1]=100;
|
||||
now[2]=200;
|
||||
now[3]=300;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
cin>>label;
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
for (i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
continue;
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
int tot;
|
||||
cin>>tot;
|
||||
for (i=1;i<=tot;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[j].y>>timeleft[i];
|
||||
}
|
||||
//Soft Ginger area
|
||||
brain();
|
||||
//dqb area
|
||||
}
|
||||
}
|
303
orz_0_2.cpp
303
orz_0_2.cpp
|
@ -1,303 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
//dqb area
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
//Soft Ginger area
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
//dqb area
|
||||
using namespace std;
|
||||
int map[20][20];
|
||||
int now[4];
|
||||
class point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
point* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
point* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new point;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new point;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
int size=0;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (0==map[i][j])
|
||||
{
|
||||
map[i][j]=now[ID];
|
||||
now[ID]++;
|
||||
size++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
score=score+size*size*10;
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID) player0->die();
|
||||
if (ID_1==ID) player1->die();
|
||||
if (ID_2==ID) player2->die();
|
||||
if (ID_3==ID) player3->die();
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID) {if (state_down==player0->state) player0->paint();player0->up();}
|
||||
if (ID_1==ID) {if (state_down==player1->state) player1->paint();player1->up();}
|
||||
if (ID_2==ID) {if (state_down==player2->state) player2->paint();player2->up();}
|
||||
if (ID_3==ID) {if (state_down==player3->state) player3->paint();player3->up();}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID) {player0->down();player0->insert(x,y);}
|
||||
if (ID_1==ID) {player1->down();player1->insert(x,y);}
|
||||
if (ID_2==ID) {player2->down();player2->insert(x,y);}
|
||||
if (ID_3==ID) {player3->down();player3->insert(x,y);}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
};
|
||||
//dqb area
|
||||
int m,n,i,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
point bind[200];
|
||||
int timeleft[200];
|
||||
enclosure* game;
|
||||
//Soft Ginger area
|
||||
ofstream fout("output.txt");
|
||||
int mode=mode_start;
|
||||
void brain()
|
||||
{
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//State Processing
|
||||
if(mode==mode_left&&now_x==10)
|
||||
{
|
||||
cout<<"[ACTION] l 1"<<endl;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
cout<<"[ACTION] r 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
cout<<"[ACTION] u 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
cout<<"[ACTION] l 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
cout<<"[ACTION] d 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
cout<<"[ACTION] s 0"<<endl;
|
||||
}
|
||||
fout<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
for(int j=1;j<=10;j++) fout<<setiosflags(ios::fixed)<<setw(4)<<map[i][j];
|
||||
fout<<endl;
|
||||
}
|
||||
fout<<"---END---"<<endl;
|
||||
fout<<endl;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
now[0]=0;
|
||||
now[1]=100;
|
||||
now[2]=200;
|
||||
now[3]=300;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for (i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
int tot;
|
||||
cin>>tot;
|
||||
for (i=1;i<=tot;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
//Soft Ginger area
|
||||
brain();
|
||||
//dqb area
|
||||
}
|
||||
}
|
303
orz_0_3.cpp
303
orz_0_3.cpp
|
@ -1,303 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
//dqb area
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
//Soft Ginger area
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
//dqb area
|
||||
using namespace std;
|
||||
int map[20][20];
|
||||
int now[4];
|
||||
class point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
point* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
point* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new point;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new point;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
int size=0;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (0==map[i][j])
|
||||
{
|
||||
map[i][j]=now[ID];
|
||||
now[ID]++;
|
||||
size++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
score=score+size*size*10;
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID) player0->die();
|
||||
if (ID_1==ID) player1->die();
|
||||
if (ID_2==ID) player2->die();
|
||||
if (ID_3==ID) player3->die();
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID) {if (state_down==player0->state) player0->paint();player0->up();}
|
||||
if (ID_1==ID) {if (state_down==player1->state) player1->paint();player1->up();}
|
||||
if (ID_2==ID) {if (state_down==player2->state) player2->paint();player2->up();}
|
||||
if (ID_3==ID) {if (state_down==player3->state) player3->paint();player3->up();}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID) {player0->down();player0->insert(x,y);}
|
||||
if (ID_1==ID) {player1->down();player1->insert(x,y);}
|
||||
if (ID_2==ID) {player2->down();player2->insert(x,y);}
|
||||
if (ID_3==ID) {player3->down();player3->insert(x,y);}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
};
|
||||
//dqb area
|
||||
int m,n,i,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
point bind[200];
|
||||
int timeleft[200];
|
||||
enclosure* game;
|
||||
//Soft Ginger area
|
||||
ofstream fout("output.txt");
|
||||
int mode=mode_start;
|
||||
void brain()
|
||||
{
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//State Processing
|
||||
if(mode==mode_left&&now_x==10)
|
||||
{
|
||||
cout<<"[ACTION] l 1"<<endl;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
cout<<"[ACTION] r 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
cout<<"[ACTION] u 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
cout<<"[ACTION] l 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
cout<<"[ACTION] d 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
cout<<"[ACTION] s 0"<<endl;
|
||||
}
|
||||
fout<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
for(int j=1;j<=10;j++) fout<<setiosflags(ios::fixed)<<setw(4)<<map[i][j];
|
||||
fout<<endl;
|
||||
}
|
||||
fout<<"---END---"<<endl;
|
||||
fout<<endl;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
now[0]=0;
|
||||
now[1]=100;
|
||||
now[2]=200;
|
||||
now[3]=300;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for (i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
int tot;
|
||||
cin>>tot;
|
||||
for (i=1;i<=tot;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
//Soft Ginger area
|
||||
brain();
|
||||
//dqb area
|
||||
}
|
||||
}
|
308
orz_0_4.cpp
308
orz_0_4.cpp
|
@ -1,308 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[20][20];
|
||||
int now[4];
|
||||
int hedge[20][20];
|
||||
int vedge[20][20];
|
||||
class point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
point* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
point* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new point;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new point;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
int size=0;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (-1==map[i][j])
|
||||
{
|
||||
map[i][j]=now[ID];
|
||||
size++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (0!=size) now[ID]++;
|
||||
score=score+size*size*10;
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID) player0->die();
|
||||
if (ID_1==ID) player1->die();
|
||||
if (ID_2==ID) player2->die();
|
||||
if (ID_3==ID) player3->die();
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID) {if (state_down==player0->state) player0->insert(x,y);player0->paint();player0->up();player0->clear();player0->insert(x,y);}
|
||||
if (ID_1==ID) {if (state_down==player1->state) player1->insert(x,y);player1->paint();player1->up();player1->clear();player1->insert(x,y);}
|
||||
if (ID_2==ID) {if (state_down==player2->state) player2->insert(x,y);player2->paint();player2->up();player2->clear();player2->insert(x,y);}
|
||||
if (ID_3==ID) {if (state_down==player3->state) player3->insert(x,y);player3->paint();player3->up();player3->clear();player3->insert(x,y);}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID) {player0->down();player0->insert(x,y);}
|
||||
if (ID_1==ID) {player1->down();player1->insert(x,y);}
|
||||
if (ID_2==ID) {player2->down();player2->insert(x,y);}
|
||||
if (ID_3==ID) {player3->down();player3->insert(x,y);}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
};
|
||||
int m,n,i,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
point bind[200];
|
||||
int timeleft[200];
|
||||
enclosure* game;
|
||||
ofstream fout("output.txt");
|
||||
int mode=mode_start;
|
||||
void update_edge_status()
|
||||
int enclosure_distance(point p1,point p2)
|
||||
{
|
||||
//Todo:
|
||||
return -1;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
if(mode==mode_left&&now_x==10)
|
||||
{
|
||||
cout<<"[ACTION] l 1"<<endl;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
cout<<"[ACTION] r 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
cout<<"[ACTION] u 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
cout<<"[ACTION] l 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
cout<<"[ACTION] d 0"<<endl;
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
cout<<"[ACTION] s 0"<<endl;
|
||||
}
|
||||
fout<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
for(int j=1;j<=10;j++) fout<<setiosflags(ios::fixed)<<setw(4)<<map[j][i];
|
||||
fout<<endl;
|
||||
}
|
||||
fout<<"---END---"<<endl;
|
||||
fout<<endl;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
now[0]=0;
|
||||
now[1]=100;
|
||||
now[2]=200;
|
||||
now[3]=300;
|
||||
for(int i=1;i<=10;i++) for(int j=1;j<=11;j++)
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for (i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
int tot;
|
||||
cin>>tot;
|
||||
for (i=1;i<=tot;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
364
orz_0_4_1.cpp
364
orz_0_4_1.cpp
|
@ -1,364 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[20][20][5];
|
||||
int now[4];
|
||||
int edge_color[20][20][20][20];
|
||||
class point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
point* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
point* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new point;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new point;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
int size=0;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (-1==map[i][j])
|
||||
{
|
||||
map[i][j]=now[ID];
|
||||
size++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (0!=size) now[ID]++;
|
||||
score=score+size*size*10;
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID) player0->die();
|
||||
if (ID_1==ID) player1->die();
|
||||
if (ID_2==ID) player2->die();
|
||||
if (ID_3==ID) player3->die();
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID) {if (state_down==player0->state) player0->insert(x,y);player0->paint();player0->up();player0->clear();player0->insert(x,y);}
|
||||
if (ID_1==ID) {if (state_down==player1->state) player1->insert(x,y);player1->paint();player1->up();player1->clear();player1->insert(x,y);}
|
||||
if (ID_2==ID) {if (state_down==player2->state) player2->insert(x,y);player2->paint();player2->up();player2->clear();player2->insert(x,y);}
|
||||
if (ID_3==ID) {if (state_down==player3->state) player3->insert(x,y);player3->paint();player3->up();player3->clear();player3->insert(x,y);}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID) {player0->down();player0->insert(x,y);}
|
||||
if (ID_1==ID) {player1->down();player1->insert(x,y);}
|
||||
if (ID_2==ID) {player2->down();player2->insert(x,y);}
|
||||
if (ID_3==ID) {player3->down();player3->insert(x,y);}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
};
|
||||
int m,n,i,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
point bind[200];
|
||||
int timeleft[200];
|
||||
enclosure* game;
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
int mode=mode_start;
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int enclosure_distance(point p1,point p2,int PID)
|
||||
{
|
||||
//Todo:
|
||||
return -1;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
|
||||
if(mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
now[0]=0;
|
||||
now[1]=100;
|
||||
now[2]=200;
|
||||
now[3]=300;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for (i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
int tot;
|
||||
cin>>tot;
|
||||
for (i=1;i<=tot;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
BIN
orz_0_4_1.exe
BIN
orz_0_4_1.exe
Binary file not shown.
364
orz_0_4_2.cpp
364
orz_0_4_2.cpp
|
@ -1,364 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[20][20][5];
|
||||
int now[4];
|
||||
int edge_color[20][20][20][20];
|
||||
class point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
point* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
point* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new point;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new point;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
int size=0;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (-1==map[i][j])
|
||||
{
|
||||
map[i][j]=now[ID];
|
||||
size++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (0!=size) now[ID]++;
|
||||
score=score+size*size*10;
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID) player0->die();
|
||||
if (ID_1==ID) player1->die();
|
||||
if (ID_2==ID) player2->die();
|
||||
if (ID_3==ID) player3->die();
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID) {if (state_down==player0->state) player0->insert(x,y);player0->paint();player0->up();player0->clear();player0->insert(x,y);}
|
||||
if (ID_1==ID) {if (state_down==player1->state) player1->insert(x,y);player1->paint();player1->up();player1->clear();player1->insert(x,y);}
|
||||
if (ID_2==ID) {if (state_down==player2->state) player2->insert(x,y);player2->paint();player2->up();player2->clear();player2->insert(x,y);}
|
||||
if (ID_3==ID) {if (state_down==player3->state) player3->insert(x,y);player3->paint();player3->up();player3->clear();player3->insert(x,y);}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID) {player0->down();player0->insert(x,y);}
|
||||
if (ID_1==ID) {player1->down();player1->insert(x,y);}
|
||||
if (ID_2==ID) {player2->down();player2->insert(x,y);}
|
||||
if (ID_3==ID) {player3->down();player3->insert(x,y);}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
};
|
||||
int m,n,i,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
point bind[200];
|
||||
int timeleft[200];
|
||||
enclosure* game;
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
int mode=mode_start;
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int enclosure_distance(point p1,point p2,int PID)
|
||||
{
|
||||
//Todo:
|
||||
return -1;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
|
||||
if(mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
now[0]=0;
|
||||
now[1]=100;
|
||||
now[2]=200;
|
||||
now[3]=300;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for (i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
int tot;
|
||||
cin>>tot;
|
||||
for (i=1;i<=tot;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
443
orz_0_4_3.cpp
443
orz_0_4_3.cpp
|
@ -1,443 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[20][20];
|
||||
int minimap[4][20][20];
|
||||
int now[4];
|
||||
int tot[4];
|
||||
int area[4];
|
||||
int edge_color[20][20][20][20];
|
||||
class point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
point* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
point* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new point;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new point;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID) {player0->die();if (player0->road[1]->x==x&&player0->road[1]->y==y){player0->insert(x,y);player0->paint();player0->clear();}}
|
||||
if (ID_1==ID) {player1->die();if (player1->road[1]->x==x&&player1->road[1]->y==y){player1->insert(x,y);player1->paint();player1->clear();}}
|
||||
if (ID_2==ID) {player2->die();if (player2->road[1]->x==x&&player2->road[1]->y==y){player2->insert(x,y);player2->paint();player2->clear();}}
|
||||
if (ID_3==ID) {player3->die();if (player3->road[1]->x==x&&player3->road[1]->y==y){player3->insert(x,y);player3->paint();player3->clear();}}
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID)
|
||||
{
|
||||
if (state_down==player0->state) player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->up();
|
||||
player0->clear();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if (ID_1==ID)
|
||||
{
|
||||
if (state_down==player1->state) player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->up();
|
||||
player1->clear();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if (ID_2==ID)
|
||||
{
|
||||
if (state_down==player2->state) player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->up();
|
||||
player2->clear();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if (ID_3==ID)
|
||||
{
|
||||
if (state_down==player3->state) player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->up();
|
||||
player3->clear();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID)
|
||||
{
|
||||
player0->down();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if (ID_1==ID)
|
||||
{
|
||||
player1->down();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if (ID_2==ID)
|
||||
{
|
||||
player2->down();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if (ID_3==ID)
|
||||
{
|
||||
player3->down();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
int i,j,k;
|
||||
for (i=0;i<=3;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
for (k=1;k<=10;k++)
|
||||
{
|
||||
if (1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for (j=1;j<=10;j++)
|
||||
for (k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for (int s=0;s<=3;s++)
|
||||
if (tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if (-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
player0->score=player0->score+area[0]*area[0]*10;
|
||||
player1->score=player1->score+area[1]*area[1]*10;
|
||||
player2->score=player2->score+area[2]*area[2]*10;
|
||||
player3->score=player3->score+area[3]*area[3]*10;
|
||||
for (i=0;i<=3;i++)
|
||||
if (0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
int m,n,i,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
point bind[200];
|
||||
int timeleft[200];
|
||||
enclosure* game;
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
int mode=mode_start;
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if (diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if (diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if (diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if (diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if (diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for (int i=0;i<=10;i++)
|
||||
{
|
||||
for (int j=0;j<=10;j++)
|
||||
{
|
||||
if (i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if (j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if (i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if (j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if (j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if (i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if (j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if (i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int enclosure_distance(point p1,point p2,int ID)
|
||||
{
|
||||
//Todo:
|
||||
return -1;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
int now_x,now_y;
|
||||
switch (now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if (mode==mode_right)
|
||||
{
|
||||
if (now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if (mode==mode_up)
|
||||
{
|
||||
if (now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if (mode==mode_left)
|
||||
{
|
||||
if (now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if (mode==mode_down)
|
||||
{
|
||||
if (now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
|
||||
if (mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if (mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if (mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if (mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if (mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if (mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for (int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for (int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
for (int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
now[0]=0;
|
||||
now[1]=100;
|
||||
now[2]=200;
|
||||
now[3]=300;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for (i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int tot;
|
||||
cin>>tot;
|
||||
for (i=1;i<=tot;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
451
orz_0_5.cpp
451
orz_0_5.cpp
|
@ -1,451 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[20][20];
|
||||
int minimap[4][20][20];
|
||||
int now[4];
|
||||
int tot[4];
|
||||
int area[4];
|
||||
int edge_color[20][20][20][20];
|
||||
class point
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
point* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
point* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new point;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new point;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID) {player0->die();if (player0->road[1]->x==x&&player0->road[1]->y==y){player0->insert(x,y);player0->paint();player0->clear();}}
|
||||
if (ID_1==ID) {player1->die();if (player1->road[1]->x==x&&player1->road[1]->y==y){player1->insert(x,y);player1->paint();player1->clear();}}
|
||||
if (ID_2==ID) {player2->die();if (player2->road[1]->x==x&&player2->road[1]->y==y){player2->insert(x,y);player2->paint();player2->clear();}}
|
||||
if (ID_3==ID) {player3->die();if (player3->road[1]->x==x&&player3->road[1]->y==y){player3->insert(x,y);player3->paint();player3->clear();}}
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID)
|
||||
{
|
||||
if (state_down==player0->state) player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->up();
|
||||
player0->clear();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if (ID_1==ID)
|
||||
{
|
||||
if (state_down==player1->state) player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->up();
|
||||
player1->clear();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if (ID_2==ID)
|
||||
{
|
||||
if (state_down==player2->state) player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->up();
|
||||
player2->clear();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if (ID_3==ID)
|
||||
{
|
||||
if (state_down==player3->state) player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->up();
|
||||
player3->clear();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID)
|
||||
{
|
||||
player0->down();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if (ID_1==ID)
|
||||
{
|
||||
player1->down();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if (ID_2==ID)
|
||||
{
|
||||
player2->down();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if (ID_3==ID)
|
||||
{
|
||||
player3->down();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
int i,j,k;
|
||||
for (i=0;i<=3;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
for (k=1;k<=10;k++)
|
||||
{
|
||||
if (1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for (j=1;j<=10;j++)
|
||||
for (k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for (int s=0;s<=3;s++)
|
||||
if (tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if (-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
player0->score=player0->score+area[0]*area[0]*10;
|
||||
player1->score=player1->score+area[1]*area[1]*10;
|
||||
player2->score=player2->score+area[2]*area[2]*10;
|
||||
player3->score=player3->score+area[3]*area[3]*10;
|
||||
for (i=0;i<=3;i++)
|
||||
if (0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
int m,n,i,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
point bind[200];
|
||||
int timeleft[200];
|
||||
enclosure* game;
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
int mode=mode_start;
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if (diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if (diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if (diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if (diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if (diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for (int i=0;i<=10;i++)
|
||||
{
|
||||
for (int j=0;j<=10;j++)
|
||||
{
|
||||
if (i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if (j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if (i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if (j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if (j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if (i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if (j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if (i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int enclosure_distance(point p1,point p2,int ID)
|
||||
{
|
||||
//Todo:
|
||||
return -1;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
int now_x,now_y;
|
||||
switch (now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if (mode==mode_right)
|
||||
{
|
||||
if (now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if (mode==mode_up)
|
||||
{
|
||||
if (now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if (mode==mode_left)
|
||||
{
|
||||
if (now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if (mode==mode_down)
|
||||
{
|
||||
if (now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
|
||||
if (mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if (mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if (mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if (mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if (mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if (mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for (int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for (int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
for (int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
for (int j=0;j<=10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[i][j][i+1][j];
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
now[0]=0;
|
||||
now[1]=100;
|
||||
now[2]=200;
|
||||
now[3]=300;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for (i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int total;
|
||||
cin>>total;
|
||||
for (i=1;i<=total;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
531
orz_0_5_1.cpp
531
orz_0_5_1.cpp
|
@ -1,531 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#include<queue>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[15][15];
|
||||
int minimap[4][15][15];
|
||||
int now[4],tot[4],area[4];
|
||||
int m,n,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
int edge_color[15][15][15][15];
|
||||
int timeleft[200];
|
||||
int mode=mode_start;
|
||||
unsigned int relative_distance[4][15][15][15][15];
|
||||
class dot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
dot* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
dot* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new dot;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new dot;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=2;k<=num;k++)
|
||||
{
|
||||
if(road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if(road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if(road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if(j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if(road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if(j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if(road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if(i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if(road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if(i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(top&&bottom&&left&&right)
|
||||
{
|
||||
if(-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if(state_die==state)
|
||||
{
|
||||
if(ID_0==ID) {player0->die();if(player0->road[1]->x==x&&player0->road[1]->y==y){player0->insert(x,y);player0->paint();player0->clear();}}
|
||||
if(ID_1==ID) {player1->die();if(player1->road[1]->x==x&&player1->road[1]->y==y){player1->insert(x,y);player1->paint();player1->clear();}}
|
||||
if(ID_2==ID) {player2->die();if(player2->road[1]->x==x&&player2->road[1]->y==y){player2->insert(x,y);player2->paint();player2->clear();}}
|
||||
if(ID_3==ID) {player3->die();if(player3->road[1]->x==x&&player3->road[1]->y==y){player3->insert(x,y);player3->paint();player3->clear();}}
|
||||
}
|
||||
if(state_up==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
if(state_down==player0->state) player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->up();
|
||||
player0->clear();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
if(state_down==player1->state) player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->up();
|
||||
player1->clear();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
if(state_down==player2->state) player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->up();
|
||||
player2->clear();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
if(state_down==player3->state) player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->up();
|
||||
player3->clear();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(state_down==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
player0->down();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
player1->down();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
player2->down();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
player3->down();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(ID_0==ID) player0->change(x,y);
|
||||
if(ID_1==ID) player1->change(x,y);
|
||||
if(ID_2==ID) player2->change(x,y);
|
||||
if(ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
int i,j,k;
|
||||
for(i=0;i<=3;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
if(1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for(int s=0;s<=3;s++)
|
||||
if(tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if(-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
player0->score=player0->score+area[0]*area[0]*10;
|
||||
player1->score=player1->score+area[1]*area[1]*10;
|
||||
player2->score=player2->score+area[2]*area[2]*10;
|
||||
player3->score=player3->score+area[3]*area[3]*10;
|
||||
for(i=0;i<=3;i++)
|
||||
if(0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
dot bind[200];
|
||||
enclosure* game;
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
ofstream fout4(".\\output4.txt");
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int update_distance(dot* start_point,int ID)
|
||||
{
|
||||
//Todo:
|
||||
//1. Get unpassable lines
|
||||
//2. Do a bfs
|
||||
//Note:
|
||||
//1. An edge label 400 means specially defined unpassable lines
|
||||
//2. This update process is only valid for a certain ID, i.e. the defined player
|
||||
unsigned int tmp_distance[15][15];
|
||||
bool in_queue[15][15];
|
||||
memset(tmp_distance,0xff,sizeof(tmp_distance));
|
||||
memset(in_queue,0,sizeof(in_queue));
|
||||
queue<dot*>* q=new queue<dot*>;
|
||||
q->push(start_point);
|
||||
tmp_distance[start_point->x][start_point->y]=0;
|
||||
while((!q->empty()))
|
||||
{
|
||||
dot* tmp=q->front();
|
||||
q->pop();
|
||||
in_queue[tmp->x][tmp->y]=false;
|
||||
if((tmp->x>0)&&(edge_color[tmp->x][tmp->y][tmp->x-1][tmp->y]==-1)&&(tmp_distance[tmp->x-1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x-1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x-1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x-1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x-1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->x<10)&&(edge_color[tmp->x][tmp->y][tmp->x+1][tmp->y]==-1)&&(tmp_distance[tmp->x+1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x+1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x+1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x+1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x+1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y>0)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y-1]==-1)&&(tmp_distance[tmp->x][tmp->y-1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y-1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y-1;
|
||||
if(!in_queue[tmp->x][tmp->y-1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y-1]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y<10)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y+1]==-1)&&(tmp_distance[tmp->x][tmp->y+1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y+1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y+1;
|
||||
if(!in_queue[tmp->x][tmp->y+1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y+1]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=10;i++) for(int j=0;j<=10;j++) relative_distance[ID][start_point->x][start_point->y][i][j]=tmp_distance[i][j];
|
||||
return -1;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
update_distance(game->player0->position,0);
|
||||
update_distance(game->player1->position,1);
|
||||
update_distance(game->player2->position,2);
|
||||
update_distance(game->player3->position,3);
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//Output Area
|
||||
if(mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
//Debug Output
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j+1][i];
|
||||
fout3<<endl;
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
fout4<<"---RELATIVE DISTANCE---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout4<<setiosflags(ios::fixed)<<setw(4)<<relative_distance[now_id][now_x][now_y][j][i];
|
||||
fout4<<endl;
|
||||
}
|
||||
fout4<<"----------END----------"<<endl;
|
||||
fout4<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for(int i=0;i<4;i++) now[i]=100*i;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
memset(relative_distance,0xff,sizeof(relative_distance));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for(int i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if(!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int total;
|
||||
cin>>total;
|
||||
for(int i=1;i<=total;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
BIN
orz_0_5_1.exe
BIN
orz_0_5_1.exe
Binary file not shown.
535
orz_0_6.cpp
535
orz_0_6.cpp
|
@ -1,535 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#include<queue>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[15][15];
|
||||
int minimap[4][15][15];
|
||||
int now[4],tot[4],area[4];
|
||||
int m,n,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
int edge_color[15][15][15][15];
|
||||
int timeleft[200];
|
||||
int mode=mode_start;
|
||||
unsigned int relative_distance[4][15][15][15][15];
|
||||
class dot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
dot* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
dot* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new dot;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new dot;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=2;k<=num;k++)
|
||||
{
|
||||
if(road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if(road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if(road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if(j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if(road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if(j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if(road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if(i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if(road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if(i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(top&&bottom&&left&&right)
|
||||
{
|
||||
if(-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if(state_die==state)
|
||||
{
|
||||
if(ID_0==ID) {player0->die();if(player0->road[1]->x==x&&player0->road[1]->y==y){player0->insert(x,y);player0->paint();player0->clear();}}
|
||||
if(ID_1==ID) {player1->die();if(player1->road[1]->x==x&&player1->road[1]->y==y){player1->insert(x,y);player1->paint();player1->clear();}}
|
||||
if(ID_2==ID) {player2->die();if(player2->road[1]->x==x&&player2->road[1]->y==y){player2->insert(x,y);player2->paint();player2->clear();}}
|
||||
if(ID_3==ID) {player3->die();if(player3->road[1]->x==x&&player3->road[1]->y==y){player3->insert(x,y);player3->paint();player3->clear();}}
|
||||
}
|
||||
if(state_up==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
if(state_down==player0->state) player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->up();
|
||||
player0->clear();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
if(state_down==player1->state) player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->up();
|
||||
player1->clear();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
if(state_down==player2->state) player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->up();
|
||||
player2->clear();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
if(state_down==player3->state) player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->up();
|
||||
player3->clear();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(state_down==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
player0->down();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
player1->down();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
player2->down();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
player3->down();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(ID_0==ID) player0->change(x,y);
|
||||
if(ID_1==ID) player1->change(x,y);
|
||||
if(ID_2==ID) player2->change(x,y);
|
||||
if(ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
int i,j,k;
|
||||
for(i=0;i<=3;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
if(1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for(int s=0;s<=3;s++)
|
||||
if(tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if(-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
player0->score=player0->score+area[0]*area[0]*10;
|
||||
player1->score=player1->score+area[1]*area[1]*10;
|
||||
player2->score=player2->score+area[2]*area[2]*10;
|
||||
player3->score=player3->score+area[3]*area[3]*10;
|
||||
for(i=0;i<=3;i++)
|
||||
if(0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
dot bind[200];
|
||||
enclosure* game;
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
ofstream fout4(".\\output4.txt");
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int update_distance(dot* start_point,int ID)
|
||||
{
|
||||
//Todo:
|
||||
//1. Get unpassable lines
|
||||
//2. Do a bfs
|
||||
//Note:
|
||||
//1. An edge label 400 means specially defined unpassable lines
|
||||
//2. This update process is only valid for a certain ID, i.e. the defined player
|
||||
unsigned int tmp_distance[15][15];
|
||||
bool in_queue[15][15];
|
||||
memset(tmp_distance,0xff,sizeof(tmp_distance));
|
||||
memset(in_queue,0,sizeof(in_queue));
|
||||
queue<dot*>* q=new queue<dot*>;
|
||||
q->push(start_point);
|
||||
tmp_distance[start_point->x][start_point->y]=0;
|
||||
while((!q->empty()))
|
||||
{
|
||||
dot* tmp=q->front();
|
||||
q->pop();
|
||||
in_queue[tmp->x][tmp->y]=false;
|
||||
if((tmp->x>0)&&(edge_color[tmp->x][tmp->y][tmp->x-1][tmp->y]==-1)&&(tmp_distance[tmp->x-1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x-1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x-1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x-1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x-1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->x<10)&&(edge_color[tmp->x][tmp->y][tmp->x+1][tmp->y]==-1)&&(tmp_distance[tmp->x+1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x+1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x+1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x+1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x+1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y>0)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y-1]==-1)&&(tmp_distance[tmp->x][tmp->y-1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y-1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y-1;
|
||||
if(!in_queue[tmp->x][tmp->y-1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y-1]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y<10)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y+1]==-1)&&(tmp_distance[tmp->x][tmp->y+1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y+1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y+1;
|
||||
if(!in_queue[tmp->x][tmp->y+1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y+1]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=10;i++) for(int j=0;j<=10;j++) relative_distance[ID][start_point->x][start_point->y][i][j]=tmp_distance[i][j];
|
||||
return -1;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
update_distance(game->player0->position,0);
|
||||
update_distance(game->player1->position,1);
|
||||
update_distance(game->player2->position,2);
|
||||
update_distance(game->player3->position,3);
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//Output Area
|
||||
if(mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
//Debug Output
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j+1][i];
|
||||
fout3<<endl;
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
fout4<<"---RELATIVE DISTANCE---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
int rd=relative_distance[now_id][now_x][now_y][j][i];
|
||||
fout4<<setiosflags(ios::fixed)<<setw(4)<<rd;
|
||||
}
|
||||
fout4<<endl;
|
||||
}
|
||||
fout4<<"----------END----------"<<endl;
|
||||
fout4<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for(int i=0;i<4;i++) now[i]=100*i;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
memset(relative_distance,0xff,sizeof(relative_distance));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for(int i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if(!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int total;
|
||||
cin>>total;
|
||||
for(int i=1;i<=total;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
535
orz_0_6_1.cpp
535
orz_0_6_1.cpp
|
@ -1,535 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#include<queue>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[15][15];
|
||||
int minimap[4][15][15];
|
||||
int now[4],tot[4],area[4];
|
||||
int m,n,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
int edge_color[15][15][15][15];
|
||||
int timeleft[200];
|
||||
int mode=mode_start;
|
||||
unsigned int relative_distance[4][15][15][15][15];
|
||||
class dot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
dot* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
dot* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new dot;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new dot;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=2;k<=num;k++)
|
||||
{
|
||||
if(road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if(road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if(road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if(j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if(road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if(j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if(road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if(i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if(road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if(i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(top&&bottom&&left&&right)
|
||||
{
|
||||
if(-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if(state_die==state)
|
||||
{
|
||||
if(ID_0==ID) {player0->die();if(player0->road[1]->x==x&&player0->road[1]->y==y){player0->insert(x,y);player0->paint();player0->clear();}}
|
||||
if(ID_1==ID) {player1->die();if(player1->road[1]->x==x&&player1->road[1]->y==y){player1->insert(x,y);player1->paint();player1->clear();}}
|
||||
if(ID_2==ID) {player2->die();if(player2->road[1]->x==x&&player2->road[1]->y==y){player2->insert(x,y);player2->paint();player2->clear();}}
|
||||
if(ID_3==ID) {player3->die();if(player3->road[1]->x==x&&player3->road[1]->y==y){player3->insert(x,y);player3->paint();player3->clear();}}
|
||||
}
|
||||
if(state_up==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
if(state_down==player0->state) player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->up();
|
||||
player0->clear();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
if(state_down==player1->state) player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->up();
|
||||
player1->clear();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
if(state_down==player2->state) player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->up();
|
||||
player2->clear();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
if(state_down==player3->state) player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->up();
|
||||
player3->clear();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(state_down==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
player0->down();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
player1->down();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
player2->down();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
player3->down();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(ID_0==ID) player0->change(x,y);
|
||||
if(ID_1==ID) player1->change(x,y);
|
||||
if(ID_2==ID) player2->change(x,y);
|
||||
if(ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
int i,j,k;
|
||||
for(i=0;i<=3;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
if(1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for(int s=0;s<=3;s++)
|
||||
if(tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if(-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
player0->score=player0->score+area[0]*area[0]*10;
|
||||
player1->score=player1->score+area[1]*area[1]*10;
|
||||
player2->score=player2->score+area[2]*area[2]*10;
|
||||
player3->score=player3->score+area[3]*area[3]*10;
|
||||
for(i=0;i<=3;i++)
|
||||
if(0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
dot bind[200];
|
||||
enclosure* game;
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
ofstream fout4(".\\output4.txt");
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int update_distance(dot* start_point,int ID)
|
||||
{
|
||||
//Todo:
|
||||
//1. Get unpassable lines
|
||||
//2. Do a bfs
|
||||
//Note:
|
||||
//1. An edge label 400 means specially defined unpassable lines
|
||||
//2. This update process is only valid for a certain ID, i.e. the defined player
|
||||
unsigned int tmp_distance[15][15];
|
||||
bool in_queue[15][15];
|
||||
memset(tmp_distance,0xff,sizeof(tmp_distance));
|
||||
memset(in_queue,0,sizeof(in_queue));
|
||||
queue<dot*>* q=new queue<dot*>;
|
||||
q->push(start_point);
|
||||
tmp_distance[start_point->x][start_point->y]=0;
|
||||
while((!q->empty()))
|
||||
{
|
||||
dot* tmp=q->front();
|
||||
q->pop();
|
||||
in_queue[tmp->x][tmp->y]=false;
|
||||
if((tmp->x>0)&&(edge_color[tmp->x][tmp->y][tmp->x-1][tmp->y]==-1)&&(tmp_distance[tmp->x-1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x-1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x-1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x-1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x-1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->x<10)&&(edge_color[tmp->x][tmp->y][tmp->x+1][tmp->y]==-1)&&(tmp_distance[tmp->x+1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x+1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x+1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x+1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x+1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y>0)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y-1]==-1)&&(tmp_distance[tmp->x][tmp->y-1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y-1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y-1;
|
||||
if(!in_queue[tmp->x][tmp->y-1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y-1]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y<10)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y+1]==-1)&&(tmp_distance[tmp->x][tmp->y+1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y+1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y+1;
|
||||
if(!in_queue[tmp->x][tmp->y+1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y+1]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=10;i++) for(int j=0;j<=10;j++) relative_distance[ID][start_point->x][start_point->y][i][j]=tmp_distance[i][j];
|
||||
return -1;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
update_distance(game->player0->position,0);
|
||||
update_distance(game->player1->position,1);
|
||||
update_distance(game->player2->position,2);
|
||||
update_distance(game->player3->position,3);
|
||||
int now_x,now_y;
|
||||
switch(now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//Output Area
|
||||
if(mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
//Debug Output
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j+1][i];
|
||||
fout3<<endl;
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
fout4<<"---RELATIVE DISTANCE---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
int rd=relative_distance[now_id][now_x][now_y][j][i];
|
||||
fout4<<setiosflags(ios::fixed)<<setw(4)<<rd;
|
||||
}
|
||||
fout4<<endl;
|
||||
}
|
||||
fout4<<"----------END----------"<<endl;
|
||||
fout4<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for(int i=0;i<4;i++) now[i]=100*i;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
memset(relative_distance,0xff,sizeof(relative_distance));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for(int i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if(!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int total;
|
||||
cin>>total;
|
||||
for(int i=1;i<=total;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
621
orz_0_6_2.cpp
621
orz_0_6_2.cpp
|
@ -1,621 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#include<queue>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
using namespace std;
|
||||
int map[15][15];
|
||||
int minimap[4][15][15];
|
||||
int now[4],tot[4],area[4];
|
||||
int m,n,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
int edge_color[15][15][15][15];
|
||||
int timeleft[200];
|
||||
int mode=mode_start;
|
||||
unsigned int relative_distance[4][15][15][15][15];
|
||||
class dot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
dot* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
dot* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new dot;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new dot;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void cut()
|
||||
{
|
||||
num--;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=num;k++)
|
||||
{
|
||||
if (road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if (road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if (road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if (j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if (road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if (j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if (j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if (road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if (i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if (road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if (i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if (i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top&&bottom&&left&&right)
|
||||
{
|
||||
if (-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if (state_die==state)
|
||||
{
|
||||
if (ID_0==ID)
|
||||
{
|
||||
player0->die();
|
||||
if (player0->road[1]->x==x&&player0->road[1]->y==y)
|
||||
{
|
||||
player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->clear();
|
||||
}
|
||||
}
|
||||
if (ID_1==ID)
|
||||
{
|
||||
player1->die();
|
||||
if (player1->road[1]->x==x&&player1->road[1]->y==y)
|
||||
{
|
||||
player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->clear();
|
||||
}
|
||||
}
|
||||
if (ID_2==ID)
|
||||
{
|
||||
player2->die();
|
||||
if (player2->road[1]->x==x&&player2->road[1]->y==y)
|
||||
{
|
||||
player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->clear();
|
||||
}
|
||||
}
|
||||
if (ID_3==ID)
|
||||
{
|
||||
player3->die();
|
||||
if (player3->road[1]->x==x&&player3->road[1]->y==y)
|
||||
{
|
||||
player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state_up==state)
|
||||
{
|
||||
if (ID_0==ID)
|
||||
{
|
||||
if (state_down==player0->state) player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->up();
|
||||
player0->clear();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if (ID_1==ID)
|
||||
{
|
||||
if (state_down==player1->state) player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->up();
|
||||
player1->clear();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if (ID_2==ID)
|
||||
{
|
||||
if (state_down==player2->state) player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->up();
|
||||
player2->clear();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if (ID_3==ID)
|
||||
{
|
||||
if (state_down==player3->state) player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->up();
|
||||
player3->clear();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if (state_down==state)
|
||||
{
|
||||
if (ID_0==ID)
|
||||
{
|
||||
player0->down();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if (ID_1==ID)
|
||||
{
|
||||
player1->down();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if (ID_2==ID)
|
||||
{
|
||||
player2->down();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if (ID_3==ID)
|
||||
{
|
||||
player3->down();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if (ID_0==ID) player0->change(x,y);
|
||||
if (ID_1==ID) player1->change(x,y);
|
||||
if (ID_2==ID) player2->change(x,y);
|
||||
if (ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
int i,j,k;
|
||||
for (i=0;i<=3;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
for (k=1;k<=10;k++)
|
||||
{
|
||||
if (1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for (j=1;j<=10;j++)
|
||||
for (k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for (int s=0;s<=3;s++)
|
||||
if (tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if (-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
player0->score=player0->score+area[0]*area[0]*10;
|
||||
player1->score=player1->score+area[1]*area[1]*10;
|
||||
player2->score=player2->score+area[2]*area[2]*10;
|
||||
player3->score=player3->score+area[3]*area[3]*10;
|
||||
for (i=0;i<=3;i++)
|
||||
if (0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
dot bind[200];
|
||||
enclosure* game;
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
ofstream fout4(".\\output4.txt");
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if (diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if (diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if (diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if (diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if (diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for (int i=0;i<=10;i++)
|
||||
{
|
||||
for (int j=0;j<=10;j++)
|
||||
{
|
||||
if (i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if (j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if (i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if (j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if (j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if (i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if (j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if (i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int update_distance(dot* start_point,int ID)
|
||||
{
|
||||
//Todo:
|
||||
//1. Get unpassable lines
|
||||
//2. Do a bfs
|
||||
//Note:
|
||||
//1. An edge label 400 means specially defined unpassable lines
|
||||
//2. This update process is only valid for a certain ID, i.e. the defined player
|
||||
unsigned int tmp_distance[15][15];
|
||||
bool in_queue[15][15];
|
||||
memset(tmp_distance,0xff,sizeof(tmp_distance));
|
||||
memset(in_queue,0,sizeof(in_queue));
|
||||
queue<dot*>* q=new queue<dot*>;
|
||||
q->push(start_point);
|
||||
tmp_distance[start_point->x][start_point->y]=0;
|
||||
while ((!q->empty()))
|
||||
{
|
||||
dot* tmp=q->front();
|
||||
q->pop();
|
||||
in_queue[tmp->x][tmp->y]=false;
|
||||
if ((tmp->x>0)&&(edge_color[tmp->x][tmp->y][tmp->x-1][tmp->y]==-1)&&(tmp_distance[tmp->x-1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x-1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x-1;
|
||||
tmp2->y=tmp->y;
|
||||
if (!in_queue[tmp->x-1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x-1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if ((tmp->x<10)&&(edge_color[tmp->x][tmp->y][tmp->x+1][tmp->y]==-1)&&(tmp_distance[tmp->x+1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x+1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x+1;
|
||||
tmp2->y=tmp->y;
|
||||
if (!in_queue[tmp->x+1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x+1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if ((tmp->y>0)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y-1]==-1)&&(tmp_distance[tmp->x][tmp->y-1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y-1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y-1;
|
||||
if (!in_queue[tmp->x][tmp->y-1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y-1]=true;
|
||||
}
|
||||
}
|
||||
if ((tmp->y<10)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y+1]==-1)&&(tmp_distance[tmp->x][tmp->y+1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y+1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y+1;
|
||||
if (!in_queue[tmp->x][tmp->y+1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y+1]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i=0;i<=10;i++) for (int j=0;j<=10;j++) relative_distance[ID][start_point->x][start_point->y][i][j]=tmp_distance[i][j];
|
||||
return -1;
|
||||
}
|
||||
int calculate_area(dot** x,int dot_num)
|
||||
{
|
||||
int i,j,k;
|
||||
int ans=0;
|
||||
for (i=1;i<=10;i++)
|
||||
for (j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for (k=2;k<=dot_num;k++)
|
||||
{
|
||||
if (x[k-1]->x==x[k]->x&&x[k-1]->y==x[k]->y) continue;
|
||||
if (x[k-1]->x==x[k]->x)
|
||||
{
|
||||
if (x[k-1]->y<x[k]->y)
|
||||
{
|
||||
if (j==x[k]->y&&i>x[k]->x) top=true;
|
||||
if (j==x[k]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
if (x[k-1]->y>x[k]->y)
|
||||
{
|
||||
if (j==x[k-1]->y&&i>x[k]->x) top=true;
|
||||
if (j==x[k-1]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (x[k-1]->y==x[k]->y)
|
||||
{
|
||||
if (x[k-1]->x<x[k]->x)
|
||||
{
|
||||
if (i==x[k]->x&&j>x[k]->y) left=true;
|
||||
if (i==x[k]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
if (x[k-1]->x>x[k]->x)
|
||||
{
|
||||
if (i==x[k-1]->x&&j>x[k]->y) left=true;
|
||||
if (i==x[k-1]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (left&&right&&top&&bottom) ans++;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
update_distance(game->player0->position,0);
|
||||
update_distance(game->player1->position,1);
|
||||
update_distance(game->player2->position,2);
|
||||
update_distance(game->player3->position,3);
|
||||
int now_x,now_y;
|
||||
switch (now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
if (mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if (mode==mode_right)
|
||||
{
|
||||
if (now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if (mode==mode_up)
|
||||
{
|
||||
if (now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if (mode==mode_left)
|
||||
{
|
||||
if (now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if (mode==mode_down)
|
||||
{
|
||||
if (now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//Output Area
|
||||
if (mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if (mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if (mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if (mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if (mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if (mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
//Debug Output
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for (int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for (int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
for (int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for (int i=0;i<=10;i++)
|
||||
{
|
||||
for (int j=0;j<10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j+1][i];
|
||||
fout3<<endl;
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
fout4<<"---RELATIVE DISTANCE---"<<endl;
|
||||
for (int i=0;i<=10;i++)
|
||||
{
|
||||
for (int j=0;j<=10;j++)
|
||||
{
|
||||
int rd=relative_distance[now_id][now_x][now_y][j][i];
|
||||
fout4<<setiosflags(ios::fixed)<<setw(4)<<rd;
|
||||
}
|
||||
fout4<<endl;
|
||||
}
|
||||
fout4<<"----------END----------"<<endl;
|
||||
fout4<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for (int i=0;i<4;i++) now[i]=100*i;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
memset(relative_distance,0xff,sizeof(relative_distance));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for (int i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if (!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int total;
|
||||
cin>>total;
|
||||
for (int i=1;i<=total;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
560
orz_0_6_3.cpp
560
orz_0_6_3.cpp
|
@ -1,560 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#include<queue>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
#define mode_idle 6
|
||||
#define mode_draw 7
|
||||
using namespace std;
|
||||
int map[15][15];
|
||||
int minimap[4][15][15];
|
||||
int now[4],tot[4],area[4];
|
||||
int m,n,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
int edge_color[15][15][15][15];
|
||||
int timeleft[200];
|
||||
int mode=mode_start;
|
||||
unsigned int relative_distance[4][15][15][15][15];
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
ofstream fout4(".\\output4.txt");
|
||||
ofstream fout5(".\\output5.txt");
|
||||
class dot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
dot* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
dot* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new dot;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new dot;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void cut()
|
||||
{
|
||||
num--;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k,s=1;
|
||||
for(i=1;i<=num-1;i++)
|
||||
if(road[i]->x==road[num]->x&&road[i]->y==road[num]->y) s=i;
|
||||
fout5<<"---------ROAD----------"<<endl;
|
||||
fout5<<"num "<<num<<endl;
|
||||
fout5<<"s "<<s<<endl;
|
||||
for(i=1;i<=num;i++)
|
||||
fout5<<road[i]->x<<" "<<road[i]->y<<endl;
|
||||
fout5<<"---------END-----------"<<endl;
|
||||
fout5<<endl;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=s+1;k<=num;k++)
|
||||
{
|
||||
if(road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if(road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if(road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if(j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if(road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if(j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if(road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if(i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if(road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if(i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(top&&bottom&&left&&right)
|
||||
{
|
||||
if(-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* players[4];
|
||||
enclosure(int* x,int* y)
|
||||
{
|
||||
for(int i=0;i<4;i++) players[i]=new player(i,x[i],y[i]);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if(state_die==state)
|
||||
{
|
||||
players[ID]->die();
|
||||
//Needs revision
|
||||
if(players[ID]->road[1]->x==x&&players[ID]->road[1]->y==y)
|
||||
{
|
||||
players[ID]->insert(x,y);
|
||||
players[ID]->paint();
|
||||
players[ID]->clear();
|
||||
}
|
||||
}
|
||||
if(state_up==state)
|
||||
{
|
||||
if(state_down==players[ID]->state) players[ID]->insert(x,y);
|
||||
players[ID]->paint();
|
||||
players[ID]->up();
|
||||
players[ID]->clear();
|
||||
players[ID]->insert(x,y);
|
||||
}
|
||||
if(state_down==state)
|
||||
{
|
||||
players[ID]->down();
|
||||
players[ID]->insert(x,y);
|
||||
}
|
||||
players[ID]->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
for(int i=0;i<=3;i++)
|
||||
for(int j=1;j<=10;j++)
|
||||
for(int k=1;k<=10;k++)
|
||||
{
|
||||
if(1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for(int j=1;j<=10;j++)
|
||||
for(int k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for(int s=0;s<=3;s++)
|
||||
if(tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if(-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
for(int i=0;i<=3;i++) players[i]->score+=area[i]*area[i]*10;
|
||||
for(int i=0;i<=3;i++) if(0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
dot bind[200];
|
||||
enclosure* game;
|
||||
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int update_distance(dot* start_point,int ID)
|
||||
{
|
||||
//Todo:
|
||||
//1. Get unpassable lines
|
||||
//2. Do a bfs
|
||||
//Note:
|
||||
//1. An edge label 400 means specially defined unpassable lines
|
||||
//2. This update process is only valid for a certain ID, i.e. the defined player
|
||||
unsigned int tmp_distance[15][15];
|
||||
bool in_queue[15][15];
|
||||
memset(tmp_distance,0xff,sizeof(tmp_distance));
|
||||
memset(in_queue,0,sizeof(in_queue));
|
||||
queue<dot*>* q=new queue<dot*>;
|
||||
q->push(start_point);
|
||||
tmp_distance[start_point->x][start_point->y]=0;
|
||||
while ((!q->empty()))
|
||||
{
|
||||
dot* tmp=q->front();
|
||||
q->pop();
|
||||
in_queue[tmp->x][tmp->y]=false;
|
||||
if((tmp->x>0)&&(edge_color[tmp->x][tmp->y][tmp->x-1][tmp->y]==-1)&&(tmp_distance[tmp->x-1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x-1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x-1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x-1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x-1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->x<10)&&(edge_color[tmp->x][tmp->y][tmp->x+1][tmp->y]==-1)&&(tmp_distance[tmp->x+1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x+1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x+1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x+1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x+1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y>0)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y-1]==-1)&&(tmp_distance[tmp->x][tmp->y-1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y-1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y-1;
|
||||
if(!in_queue[tmp->x][tmp->y-1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y-1]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y<10)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y+1]==-1)&&(tmp_distance[tmp->x][tmp->y+1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y+1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y+1;
|
||||
if(!in_queue[tmp->x][tmp->y+1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y+1]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=10;i++) for(int j=0;j<=10;j++) relative_distance[ID][start_point->x][start_point->y][i][j]=tmp_distance[i][j];
|
||||
return -1;
|
||||
}
|
||||
int calculate_area(dot** x,int dot_num)
|
||||
{
|
||||
int i,j,k,s=1;
|
||||
int ans=0;
|
||||
for(i=1;i<=dot_num-1;i++)
|
||||
if(x[i]->x==x[dot_num]->x&&x[i]->y==x[dot_num]->y) s=i;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=s+1;k<=dot_num;k++)
|
||||
{
|
||||
if(x[k-1]->x==x[k]->x&&x[k-1]->y==x[k]->y) continue;
|
||||
if(x[k-1]->x==x[k]->x)
|
||||
{
|
||||
if(x[k-1]->y<x[k]->y)
|
||||
{
|
||||
if(j==x[k]->y&&i>x[k]->x) top=true;
|
||||
if(j==x[k]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
if(x[k-1]->y>x[k]->y)
|
||||
{
|
||||
if(j==x[k-1]->y&&i>x[k]->x) top=true;
|
||||
if(j==x[k-1]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(x[k-1]->y==x[k]->y)
|
||||
{
|
||||
if(x[k-1]->x<x[k]->x)
|
||||
{
|
||||
if(i==x[k]->x&&j>x[k]->y) left=true;
|
||||
if(i==x[k]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
if(x[k-1]->x>x[k]->x)
|
||||
{
|
||||
if(i==x[k-1]->x&&j>x[k]->y) left=true;
|
||||
if(i==x[k-1]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(left&&right&&top&&bottom&&-1==map[i][j]) ans++;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
int calculate_maximum_safe_enclosure(int now_id)
|
||||
{
|
||||
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
int original_edge_color[15][15][15][15];
|
||||
memcpy(original_edge_color,edge_color,sizeof(original_edge_color));
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
memcpy(edge_color,original_edge_color,sizeof(edge_color));
|
||||
if(game->players[i]->state==state_down)
|
||||
{
|
||||
for(int j=1;j<game->players[i]->num;j++)
|
||||
{
|
||||
dot* p1=new dot();
|
||||
dot* p2=new dot();
|
||||
p1=game->players[i]->road[j];
|
||||
p2=game->players[i]->road[j+1];
|
||||
edge_color[p1->x][p1->y][p2->x][p2->y]=edge_color[p2->x][p2->y][p1->x][p1->y]=400;
|
||||
}
|
||||
}
|
||||
else if(game->players[i]->state==state_up)
|
||||
{
|
||||
//Downward Road
|
||||
for(int j=0;j<10;j++) for(int k=0;k<=10;k++) if((edge_color[j][k][j+1][k]/100)==i) edge_color[j][k][j+1][k]=-1;
|
||||
//Upward Road
|
||||
for(int j=1;j<=10;j++) for(int k=0;k<=10;k++) if((edge_color[j][k][j-1][k]/100)==i) edge_color[j][k][j-1][k]=-1;
|
||||
//Rightward Road
|
||||
for(int j=0;j<=10;j++) for(int k=0;k<10;k++) if((edge_color[j][k][j][k+1]/100)==i) edge_color[j][k][j][k+1]=-1;
|
||||
//Leftward Road
|
||||
for(int j=0;j<=10;j++) for(int k=1;k<=10;k++) if((edge_color[j][k][j][k-1]/100)==i) edge_color[j][k][j][k-1]=-1;
|
||||
}
|
||||
update_distance(game->players[i]->position,i);
|
||||
}
|
||||
memcpy(edge_color,original_edge_color,sizeof(edge_color));
|
||||
int now_x[4],now_y[4];
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
now_x[i]=game->players[i]->position->x;
|
||||
now_y[i]=game->players[i]->position->y;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x[now_id]==10&&now_y[now_id]==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x[now_id]==0&&now_y[now_id]==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x[now_id]==0&&now_y[now_id]==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x[now_id]==10&&now_y[now_id]==0) mode=mode_halt;
|
||||
}
|
||||
//Output Area
|
||||
if(mode==mode_right&&now_y[now_id]==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
//Debug Output
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j+1][i];
|
||||
fout3<<endl;
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
fout4<<"---RELATIVE DISTANCE---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
int rd=relative_distance[now_id][now_x[now_id]][now_y[now_id]][j][i];
|
||||
fout4<<setiosflags(ios::fixed)<<setw(4)<<rd;
|
||||
}
|
||||
fout4<<endl;
|
||||
}
|
||||
fout4<<"----------END----------"<<endl;
|
||||
fout4<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for(int i=0;i<4;i++) now[i]=100*i;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
memset(relative_distance,0xff,sizeof(relative_distance));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for(int i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if(!started)
|
||||
{
|
||||
started=true;
|
||||
//game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
game=new enclosure(x,y);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int total;
|
||||
cin>>total;
|
||||
for(int i=1;i<=total;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
BIN
orz_0_6_3.exe
BIN
orz_0_6_3.exe
Binary file not shown.
657
orz_0_6_4.cpp
657
orz_0_6_4.cpp
|
@ -1,657 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#include<queue>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
#define mode_idle 6
|
||||
#define mode_draw 7
|
||||
using namespace std;
|
||||
int map[15][15];
|
||||
int minimap[4][15][15];
|
||||
int now[4],tot[4],area[4];
|
||||
int m,n,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
int edge_color[15][15][15][15];
|
||||
int timeleft[200];
|
||||
int mode=mode_start;
|
||||
unsigned int relative_distance[4][15][15][15][15];
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
ofstream fout4(".\\output4.txt");
|
||||
ofstream fout5(".\\output5.txt");
|
||||
class dot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
dot* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
dot* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new dot;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new dot;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void cut()
|
||||
{
|
||||
num--;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k,s=1;
|
||||
for(i=1;i<=num-1;i++)
|
||||
if(road[i]->x==road[num]->x&&road[i]->y==road[num]->y) s=i;
|
||||
fout5<<"---------ROAD----------"<<endl;
|
||||
fout5<<"num "<<num<<endl;
|
||||
fout5<<"s "<<s<<endl;
|
||||
for(i=1;i<=num;i++)
|
||||
fout5<<road[i]->x<<" "<<road[i]->y<<endl;
|
||||
fout5<<"---------END-----------"<<endl;
|
||||
fout5<<endl;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=s+1;k<=num;k++)
|
||||
{
|
||||
if(road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if(road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if(road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if(j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if(road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if(j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if(road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if(i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if(road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if(i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(top&&bottom&&left&&right)
|
||||
{
|
||||
if(-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
/*
|
||||
player* player0;
|
||||
player* player1;
|
||||
player* player2;
|
||||
player* player3;
|
||||
player* players[4];
|
||||
*/
|
||||
enclosure(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)
|
||||
{
|
||||
player0=new player(ID_0,x0,y0);
|
||||
player1=new player(ID_1,x1,y1);
|
||||
player2=new player(ID_2,x2,y2);
|
||||
player3=new player(ID_3,x3,y3);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if(state_die==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
player0->die();
|
||||
if(player0->road[1]->x==x&&player0->road[1]->y==y)
|
||||
{
|
||||
player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->clear();
|
||||
}
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
player1->die();
|
||||
if(player1->road[1]->x==x&&player1->road[1]->y==y)
|
||||
{
|
||||
player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->clear();
|
||||
}
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
player2->die();
|
||||
if(player2->road[1]->x==x&&player2->road[1]->y==y)
|
||||
{
|
||||
player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->clear();
|
||||
}
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
player3->die();
|
||||
if(player3->road[1]->x==x&&player3->road[1]->y==y)
|
||||
{
|
||||
player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(state_up==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
if(state_down==player0->state) player0->insert(x,y);
|
||||
player0->paint();
|
||||
player0->up();
|
||||
player0->clear();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
if(state_down==player1->state) player1->insert(x,y);
|
||||
player1->paint();
|
||||
player1->up();
|
||||
player1->clear();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
if(state_down==player2->state) player2->insert(x,y);
|
||||
player2->paint();
|
||||
player2->up();
|
||||
player2->clear();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
if(state_down==player3->state) player3->insert(x,y);
|
||||
player3->paint();
|
||||
player3->up();
|
||||
player3->clear();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(state_down==state)
|
||||
{
|
||||
if(ID_0==ID)
|
||||
{
|
||||
player0->down();
|
||||
player0->insert(x,y);
|
||||
}
|
||||
if(ID_1==ID)
|
||||
{
|
||||
player1->down();
|
||||
player1->insert(x,y);
|
||||
}
|
||||
if(ID_2==ID)
|
||||
{
|
||||
player2->down();
|
||||
player2->insert(x,y);
|
||||
}
|
||||
if(ID_3==ID)
|
||||
{
|
||||
player3->down();
|
||||
player3->insert(x,y);
|
||||
}
|
||||
}
|
||||
if(ID_0==ID) player0->change(x,y);
|
||||
if(ID_1==ID) player1->change(x,y);
|
||||
if(ID_2==ID) player2->change(x,y);
|
||||
if(ID_3==ID) player3->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
int i,j,k;
|
||||
for(i=0;i<=3;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
if(1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for(j=1;j<=10;j++)
|
||||
for(k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for(int s=0;s<=3;s++)
|
||||
if(tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if(-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
player0->score=player0->score+area[0]*area[0]*10;
|
||||
player1->score=player1->score+area[1]*area[1]*10;
|
||||
player2->score=player2->score+area[2]*area[2]*10;
|
||||
player3->score=player3->score+area[3]*area[3]*10;
|
||||
for(i=0;i<=3;i++)
|
||||
if(0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
dot bind[200];
|
||||
enclosure* game;
|
||||
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int update_distance(dot* start_point,int ID)
|
||||
{
|
||||
//Todo:
|
||||
//1. Get unpassable lines
|
||||
//2. Do a bfs
|
||||
//Note:
|
||||
//1. An edge label 400 means specially defined unpassable lines
|
||||
//2. This update process is only valid for a certain ID, i.e. the defined player
|
||||
unsigned int tmp_distance[15][15];
|
||||
bool in_queue[15][15];
|
||||
memset(tmp_distance,0xff,sizeof(tmp_distance));
|
||||
memset(in_queue,0,sizeof(in_queue));
|
||||
queue<dot*>* q=new queue<dot*>;
|
||||
q->push(start_point);
|
||||
tmp_distance[start_point->x][start_point->y]=0;
|
||||
while ((!q->empty()))
|
||||
{
|
||||
dot* tmp=q->front();
|
||||
q->pop();
|
||||
in_queue[tmp->x][tmp->y]=false;
|
||||
if((tmp->x>0)&&(edge_color[tmp->x][tmp->y][tmp->x-1][tmp->y]==-1)&&(tmp_distance[tmp->x-1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x-1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x-1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x-1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x-1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->x<10)&&(edge_color[tmp->x][tmp->y][tmp->x+1][tmp->y]==-1)&&(tmp_distance[tmp->x+1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x+1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x+1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x+1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x+1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y>0)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y-1]==-1)&&(tmp_distance[tmp->x][tmp->y-1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y-1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y-1;
|
||||
if(!in_queue[tmp->x][tmp->y-1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y-1]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y<10)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y+1]==-1)&&(tmp_distance[tmp->x][tmp->y+1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y+1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y+1;
|
||||
if(!in_queue[tmp->x][tmp->y+1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y+1]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=10;i++) for(int j=0;j<=10;j++) relative_distance[ID][start_point->x][start_point->y][i][j]=tmp_distance[i][j];
|
||||
return -1;
|
||||
}
|
||||
int calculate_area(dot** x,int dot_num)
|
||||
{
|
||||
int i,j,k,s=1;
|
||||
int ans=0;
|
||||
for(i=1;i<=dot_num-1;i++)
|
||||
if(x[i]->x==x[dot_num]->x&&x[i]->y==x[dot_num]->y) s=i;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=s+1;k<=dot_num;k++)
|
||||
{
|
||||
if(x[k-1]->x==x[k]->x&&x[k-1]->y==x[k]->y) continue;
|
||||
if(x[k-1]->x==x[k]->x)
|
||||
{
|
||||
if(x[k-1]->y<x[k]->y)
|
||||
{
|
||||
if(j==x[k]->y&&i>x[k]->x) top=true;
|
||||
if(j==x[k]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
if(x[k-1]->y>x[k]->y)
|
||||
{
|
||||
if(j==x[k-1]->y&&i>x[k]->x) top=true;
|
||||
if(j==x[k-1]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(x[k-1]->y==x[k]->y)
|
||||
{
|
||||
if(x[k-1]->x<x[k]->x)
|
||||
{
|
||||
if(i==x[k]->x&&j>x[k]->y) left=true;
|
||||
if(i==x[k]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
if(x[k-1]->x>x[k]->x)
|
||||
{
|
||||
if(i==x[k-1]->x&&j>x[k]->y) left=true;
|
||||
if(i==x[k-1]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(left&&right&&top&&bottom&&-1==map[i][j]) ans++;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
int calculate_maximum_safe_enclosure(int now_id)
|
||||
{
|
||||
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
int original_edge_color[15][15][15][15];
|
||||
memcpy(original_edge_color,edge_color,sizeof(original_edge_color));
|
||||
if(game->player0->state=state_down)
|
||||
{
|
||||
memcpy(edge_color,original_edge_color,sizeof(edge_color));
|
||||
for(int i=1;i<game->player0->num;i++)
|
||||
{
|
||||
dot* p1=game->player0->road[i];
|
||||
dot* p2=game->player0->road[i+1];
|
||||
edge_color[p1->x][p1->y][p2->x][p2->y]=edge_color[p2->x][p2->y][p1->x][p1->y]=400;
|
||||
}
|
||||
}
|
||||
|
||||
update_distance(game->player1->position,1);
|
||||
update_distance(game->player2->position,2);
|
||||
update_distance(game->player3->position,3);
|
||||
int now_x,now_y;
|
||||
switch (now_id)
|
||||
{
|
||||
case 0:
|
||||
now_x=game->player0->position->x;
|
||||
now_y=game->player0->position->y;
|
||||
break;
|
||||
case 1:
|
||||
now_x=game->player1->position->x;
|
||||
now_y=game->player1->position->y;
|
||||
break;
|
||||
case 2:
|
||||
now_x=game->player2->position->x;
|
||||
now_y=game->player2->position->y;
|
||||
break;
|
||||
case 3:
|
||||
now_x=game->player3->position->x;
|
||||
now_y=game->player3->position->y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Finite State Machine
|
||||
/*Whole closure
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x==10&&now_y==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x==0&&now_y==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x==0&&now_y==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x==10&&now_y==0) mode=mode_halt;
|
||||
}
|
||||
//Output Area
|
||||
if(mode==mode_right&&now_y==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
*/
|
||||
//Debug Output
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j+1][i];
|
||||
fout3<<endl;
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
fout4<<"---RELATIVE DISTANCE---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
int rd=relative_distance[now_id][now_x][now_y][j][i];
|
||||
fout4<<setiosflags(ios::fixed)<<setw(4)<<rd;
|
||||
}
|
||||
fout4<<endl;
|
||||
}
|
||||
fout4<<"----------END----------"<<endl;
|
||||
fout4<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for(int i=0;i<4;i++) now[i]=100*i;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
memset(relative_distance,0xff,sizeof(relative_distance));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for(int i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if(!started)
|
||||
{
|
||||
started=true;
|
||||
game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int total;
|
||||
cin>>total;
|
||||
for(int i=1;i<=total;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
558
orz_0_6_6.cpp
558
orz_0_6_6.cpp
|
@ -1,558 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#include<queue>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define ID_0 0
|
||||
#define ID_1 1
|
||||
#define ID_2 2
|
||||
#define ID_3 3
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
#define mode_idle 6
|
||||
#define mode_draw 7
|
||||
using namespace std;
|
||||
int map[15][15];
|
||||
int minimap[4][15][15];
|
||||
int now[4],tot[4],area[4];
|
||||
int m,n,j,k;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
int edge_color[15][15][15][15];
|
||||
int timeleft[200];
|
||||
int mode=mode_start;
|
||||
unsigned int relative_distance[4][15][15][15][15];
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
ofstream fout4(".\\output4.txt");
|
||||
ofstream fout5(".\\output5.txt");
|
||||
class dot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
dot* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
dot* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new dot;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new dot;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void cut()
|
||||
{
|
||||
num--;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k,s=1;
|
||||
for(i=1;i<=num-1;i++)
|
||||
if(road[i]->x==road[num]->x&&road[i]->y==road[num]->y) s=i;
|
||||
fout5<<"---------ROAD----------"<<endl;
|
||||
fout5<<"num "<<num<<endl;
|
||||
fout5<<"s "<<s<<endl;
|
||||
for(i=1;i<=num;i++)
|
||||
fout5<<road[i]->x<<" "<<road[i]->y<<endl;
|
||||
fout5<<"---------END-----------"<<endl;
|
||||
fout5<<endl;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=s+1;k<=num;k++)
|
||||
{
|
||||
if(road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if(road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if(road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if(j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if(road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if(j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if(road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if(i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if(road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if(i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(top&&bottom&&left&&right)
|
||||
{
|
||||
if(-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* players[4];
|
||||
enclosure(int* x,int* y)
|
||||
{
|
||||
for(int i=0;i<4;i++) players[i]=new player(i,x[i],y[i]);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if(state_die==state)
|
||||
{
|
||||
players[ID]->die();
|
||||
//Needs revision
|
||||
players[ID]->insert(x,y);
|
||||
players[ID]->paint();
|
||||
players[ID]->clear();
|
||||
}
|
||||
if(state_up==state)
|
||||
{
|
||||
if(state_down==players[ID]->state) players[ID]->insert(x,y);
|
||||
players[ID]->paint();
|
||||
players[ID]->up();
|
||||
players[ID]->clear();
|
||||
players[ID]->insert(x,y);
|
||||
}
|
||||
if(state_down==state)
|
||||
{
|
||||
players[ID]->down();
|
||||
players[ID]->insert(x,y);
|
||||
}
|
||||
players[ID]->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
for(int i=0;i<=3;i++)
|
||||
for(int j=1;j<=10;j++)
|
||||
for(int k=1;k<=10;k++)
|
||||
{
|
||||
if(1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for(int j=1;j<=10;j++)
|
||||
for(int k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for(int s=0;s<=3;s++)
|
||||
if(tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if(-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
for(int i=0;i<=3;i++) players[i]->score+=area[i]*area[i]*10;
|
||||
for(int i=0;i<=3;i++) if(0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
dot bind[200];
|
||||
enclosure* game;
|
||||
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
//Upward Road
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
//Downward Road
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
//Leftward Road
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
//Rightward Road
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int update_distance(dot* start_point,int ID)
|
||||
{
|
||||
//Todo:
|
||||
//1. Get unpassable lines
|
||||
//2. Do a bfs
|
||||
//Note:
|
||||
//1. An edge label 400 means specially defined unpassable lines
|
||||
//2. This update process is only valid for a certain ID, i.e. the defined player
|
||||
unsigned int tmp_distance[15][15];
|
||||
bool in_queue[15][15];
|
||||
memset(tmp_distance,0xff,sizeof(tmp_distance));
|
||||
memset(in_queue,0,sizeof(in_queue));
|
||||
queue<dot*>* q=new queue<dot*>;
|
||||
q->push(start_point);
|
||||
tmp_distance[start_point->x][start_point->y]=0;
|
||||
while ((!q->empty()))
|
||||
{
|
||||
dot* tmp=q->front();
|
||||
q->pop();
|
||||
in_queue[tmp->x][tmp->y]=false;
|
||||
if((tmp->x>0)&&(edge_color[tmp->x][tmp->y][tmp->x-1][tmp->y]==-1)&&(tmp_distance[tmp->x-1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x-1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x-1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x-1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x-1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->x<10)&&(edge_color[tmp->x][tmp->y][tmp->x+1][tmp->y]==-1)&&(tmp_distance[tmp->x+1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x+1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x+1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x+1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x+1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y>0)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y-1]==-1)&&(tmp_distance[tmp->x][tmp->y-1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y-1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y-1;
|
||||
if(!in_queue[tmp->x][tmp->y-1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y-1]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y<10)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y+1]==-1)&&(tmp_distance[tmp->x][tmp->y+1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y+1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y+1;
|
||||
if(!in_queue[tmp->x][tmp->y+1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y+1]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=10;i++) for(int j=0;j<=10;j++) relative_distance[ID][start_point->x][start_point->y][i][j]=tmp_distance[i][j];
|
||||
return -1;
|
||||
}
|
||||
int calculate_area(dot** x,int dot_num)
|
||||
{
|
||||
int i,j,k,s=1;
|
||||
int ans=0;
|
||||
for(i=1;i<=dot_num-1;i++)
|
||||
if(x[i]->x==x[dot_num]->x&&x[i]->y==x[dot_num]->y) s=i;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=s+1;k<=dot_num;k++)
|
||||
{
|
||||
if(x[k-1]->x==x[k]->x&&x[k-1]->y==x[k]->y) continue;
|
||||
if(x[k-1]->x==x[k]->x)
|
||||
{
|
||||
if(x[k-1]->y<x[k]->y)
|
||||
{
|
||||
if(j==x[k]->y&&i>x[k]->x) top=true;
|
||||
if(j==x[k]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
if(x[k-1]->y>x[k]->y)
|
||||
{
|
||||
if(j==x[k-1]->y&&i>x[k]->x) top=true;
|
||||
if(j==x[k-1]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(x[k-1]->y==x[k]->y)
|
||||
{
|
||||
if(x[k-1]->x<x[k]->x)
|
||||
{
|
||||
if(i==x[k]->x&&j>x[k]->y) left=true;
|
||||
if(i==x[k]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
if(x[k-1]->x>x[k]->x)
|
||||
{
|
||||
if(i==x[k-1]->x&&j>x[k]->y) left=true;
|
||||
if(i==x[k-1]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(left&&right&&top&&bottom&&-1==map[i][j]) ans++;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
int calculate_maximum_safe_enclosure(int now_id,int road_id)
|
||||
{
|
||||
//Todo:
|
||||
//1. Fetch the road from road_id to
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
update_edge_status();
|
||||
int original_edge_color[15][15][15][15];
|
||||
memcpy(original_edge_color,edge_color,sizeof(original_edge_color));
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
memcpy(edge_color,original_edge_color,sizeof(edge_color));
|
||||
if(game->players[i]->state==state_down)
|
||||
{
|
||||
for(int j=1;j<game->players[i]->num;j++)
|
||||
{
|
||||
dot* p1=new dot();
|
||||
dot* p2=new dot();
|
||||
p1=game->players[i]->road[j];
|
||||
p2=game->players[i]->road[j+1];
|
||||
edge_color[p1->x][p1->y][p2->x][p2->y]=edge_color[p2->x][p2->y][p1->x][p1->y]=400;
|
||||
}
|
||||
}
|
||||
else if(game->players[i]->state==state_up)
|
||||
{
|
||||
//Downward Road
|
||||
for(int j=0;j<10;j++) for(int k=0;k<=10;k++) if((edge_color[j][k][j+1][k]/100)==i) edge_color[j][k][j+1][k]=-1;
|
||||
//Upward Road
|
||||
for(int j=1;j<=10;j++) for(int k=0;k<=10;k++) if((edge_color[j][k][j-1][k]/100)==i) edge_color[j][k][j-1][k]=-1;
|
||||
//Rightward Road
|
||||
for(int j=0;j<=10;j++) for(int k=0;k<10;k++) if((edge_color[j][k][j][k+1]/100)==i) edge_color[j][k][j][k+1]=-1;
|
||||
//Leftward Road
|
||||
for(int j=0;j<=10;j++) for(int k=1;k<=10;k++) if((edge_color[j][k][j][k-1]/100)==i) edge_color[j][k][j][k-1]=-1;
|
||||
}
|
||||
update_distance(game->players[i]->position,i);
|
||||
}
|
||||
memcpy(edge_color,original_edge_color,sizeof(edge_color));
|
||||
int now_x[4],now_y[4];
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
now_x[i]=game->players[i]->position->x;
|
||||
now_y[i]=game->players[i]->position->y;
|
||||
}
|
||||
//Finite State Machine
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x[now_id]==10&&now_y[now_id]==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x[now_id]==0&&now_y[now_id]==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x[now_id]==0&&now_y[now_id]==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x[now_id]==10&&now_y[now_id]==0) mode=mode_halt;
|
||||
}
|
||||
//Output Area
|
||||
if(mode==mode_right&&now_y[now_id]==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
//Debug Output
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j+1][i];
|
||||
fout3<<endl;
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
fout4<<"---RELATIVE DISTANCE---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
int rd=relative_distance[now_id][now_x[now_id]][now_y[now_id]][j][i];
|
||||
fout4<<setiosflags(ios::fixed)<<setw(4)<<rd;
|
||||
}
|
||||
fout4<<endl;
|
||||
}
|
||||
fout4<<"----------END----------"<<endl;
|
||||
fout4<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for(int i=0;i<4;i++) now[i]=100*i;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
memset(relative_distance,0xff,sizeof(relative_distance));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for(int i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if(!started)
|
||||
{
|
||||
started=true;
|
||||
//game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
game=new enclosure(x,y);
|
||||
}
|
||||
game->pass(ID_0,x[0],y[0],state[0]);
|
||||
game->pass(ID_1,x[1],y[1],state[1]);
|
||||
game->pass(ID_2,x[2],y[2],state[2]);
|
||||
game->pass(ID_3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
int total;
|
||||
cin>>total;
|
||||
for(int i=1;i<=total;i++)
|
||||
{
|
||||
cin>>bind[i].x>>bind[i].y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
801
orz_0_6_8.cpp
801
orz_0_6_8.cpp
|
@ -1,801 +0,0 @@
|
|||
#include<cstdio>
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<cstdlib>
|
||||
#include<queue>
|
||||
#include<stack>
|
||||
#include<cmath>
|
||||
#include<climits>
|
||||
#define state_up 0
|
||||
#define state_down 1
|
||||
#define state_die -1
|
||||
#define mode_start 0
|
||||
#define mode_right 1
|
||||
#define mode_up 2
|
||||
#define mode_left 3
|
||||
#define mode_down 4
|
||||
#define mode_halt 5
|
||||
#define mode_idle 6
|
||||
#define mode_draw 7
|
||||
using namespace std;
|
||||
int map[15][15];
|
||||
int minimap[4][15][15];
|
||||
int now[4],tot[4],area[4];
|
||||
int m,n,bind_total;
|
||||
int x[4],y[4],state[4],trappedleft[4],scoredecline[4];
|
||||
int now_id;
|
||||
int edge_color[15][15][15][15];
|
||||
int timeleft[200];
|
||||
int mode=mode_start;
|
||||
unsigned int relative_distance[4][15][15][15][15];
|
||||
ofstream fout1(".\\output1.txt");
|
||||
ofstream fout2(".\\output2.txt");
|
||||
ofstream fout3(".\\output3.txt");
|
||||
ofstream fout4(".\\output4.txt");
|
||||
ofstream fout5(".\\output5.txt");
|
||||
ofstream fout6(".\\output6.txt");
|
||||
class dot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
class exdot
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
int meta[10];
|
||||
};
|
||||
class player
|
||||
{
|
||||
public:
|
||||
dot* position;
|
||||
int ID;
|
||||
int score;
|
||||
int state;
|
||||
int trappedleft;
|
||||
int num;
|
||||
dot* road[300];
|
||||
player(int ID,int x,int y)
|
||||
{
|
||||
position=new dot;
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
this->ID=ID;
|
||||
score=4-ID;
|
||||
state=state_up;
|
||||
trappedleft=0;
|
||||
num=0;
|
||||
}
|
||||
void insert(int x,int y)
|
||||
{
|
||||
num++;
|
||||
road[num]=new dot;
|
||||
road[num]->x=x;
|
||||
road[num]->y=y;
|
||||
}
|
||||
void cut()
|
||||
{
|
||||
num--;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
num=0;
|
||||
}
|
||||
void change(int x,int y)
|
||||
{
|
||||
position->x=x;
|
||||
position->y=y;
|
||||
}
|
||||
void down()
|
||||
{
|
||||
this->state=state_down;
|
||||
}
|
||||
void up()
|
||||
{
|
||||
this->state=state_up;
|
||||
}
|
||||
void die()
|
||||
{
|
||||
this->state=state_die;
|
||||
}
|
||||
void paint()
|
||||
{
|
||||
int i,j,k,s=1;
|
||||
for(i=1;i<=num-1;i++)
|
||||
if(road[i]->x==road[num]->x&&road[i]->y==road[num]->y) s=i;
|
||||
fout5<<"---------ROAD----------"<<endl;
|
||||
fout5<<"num "<<num<<endl;
|
||||
fout5<<"s "<<s<<endl;
|
||||
for(i=1;i<=num;i++)
|
||||
fout5<<road[i]->x<<" "<<road[i]->y<<endl;
|
||||
fout5<<"---------END-----------"<<endl;
|
||||
fout5<<endl;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=s+1;k<=num;k++)
|
||||
{
|
||||
if(road[k-1]->x==road[k]->x&&road[k-1]->y==road[k]->y) continue;
|
||||
if(road[k-1]->x==road[k]->x)
|
||||
{
|
||||
if(road[k-1]->y<road[k]->y)
|
||||
{
|
||||
if(j==road[k]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
if(road[k-1]->y>road[k]->y)
|
||||
{
|
||||
if(j==road[k-1]->y&&i>road[k]->x) top=true;
|
||||
if(j==road[k-1]->y&&i<=road[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(road[k-1]->y==road[k]->y)
|
||||
{
|
||||
if(road[k-1]->x<road[k]->x)
|
||||
{
|
||||
if(i==road[k]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
if(road[k-1]->x>road[k]->x)
|
||||
{
|
||||
if(i==road[k-1]->x&&j>road[k]->y) left=true;
|
||||
if(i==road[k-1]->x&&j<=road[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(top&&bottom&&left&&right)
|
||||
{
|
||||
if(-1==map[i][j])
|
||||
{
|
||||
minimap[ID][i][j]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
num=0;
|
||||
}
|
||||
};
|
||||
|
||||
class enclosure
|
||||
{
|
||||
public:
|
||||
player* players[4];
|
||||
enclosure(int* x,int* y)
|
||||
{
|
||||
for(int i=0;i<4;i++) players[i]=new player(i,x[i],y[i]);
|
||||
}
|
||||
enclosure(){}
|
||||
void pass(int ID,int x,int y,int state)
|
||||
{
|
||||
if(state_die==state)
|
||||
{
|
||||
players[ID]->die();
|
||||
players[ID]->insert(x,y);
|
||||
players[ID]->paint();
|
||||
players[ID]->clear();
|
||||
}
|
||||
if(state_up==state)
|
||||
{
|
||||
if(state_down==players[ID]->state) players[ID]->insert(x,y);
|
||||
players[ID]->paint();
|
||||
players[ID]->up();
|
||||
players[ID]->clear();
|
||||
players[ID]->insert(x,y);
|
||||
}
|
||||
if(state_down==state)
|
||||
{
|
||||
players[ID]->down();
|
||||
players[ID]->insert(x,y);
|
||||
}
|
||||
players[ID]->change(x,y);
|
||||
}
|
||||
void make()
|
||||
{
|
||||
for(int i=0;i<=3;i++)
|
||||
for(int j=1;j<=10;j++)
|
||||
for(int k=1;k<=10;k++)
|
||||
{
|
||||
if(1==minimap[i][j][k]) tot[i]++;
|
||||
}
|
||||
|
||||
for(int j=1;j<=10;j++)
|
||||
for(int k=1;k<=10;k++)
|
||||
{
|
||||
int mini=10000000;
|
||||
int minID=-1;
|
||||
for(int s=0;s<=3;s++)
|
||||
if(tot[s]<mini&&1==minimap[s][j][k])
|
||||
{
|
||||
mini=tot[s];
|
||||
minID=s;
|
||||
}
|
||||
if(-1==minID) continue;
|
||||
map[j][k]=now[minID];
|
||||
area[minID]++;
|
||||
}
|
||||
for(int i=0;i<=3;i++) players[i]->score+=area[i]*area[i]*10;
|
||||
for(int i=0;i<=3;i++) if(0!=area[i]) now[i]++;
|
||||
memset(minimap,0,sizeof(minimap));
|
||||
memset(area,0,sizeof(area));
|
||||
memset(tot,0,sizeof(tot));
|
||||
}
|
||||
};
|
||||
dot* bind[200];
|
||||
dot* bestroad[300];
|
||||
enclosure* game;
|
||||
|
||||
void generate_output(int diff_x,int diff_y,int other_action)
|
||||
{
|
||||
cout<<"[ACTION] ";
|
||||
if(diff_x==0&&diff_y==0) cout<<"s ";
|
||||
else if(diff_x==0&&diff_y==1) cout<<"d ";
|
||||
else if(diff_x==0&&diff_y==-1) cout<<"u ";
|
||||
else if(diff_x==1&&diff_y==0) cout<<"r ";
|
||||
else if(diff_x==-1&&diff_y==0) cout<<"l ";
|
||||
cout<<other_action<<endl;
|
||||
}
|
||||
void update_edge_status()
|
||||
{
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
if(i>0)
|
||||
{
|
||||
if(j==0||j==10||map[i][j]!=map[i][j+1]||map[i][j]==-1||map[i][j+1]==-1) edge_color[i][j][i-1][j]=-1;
|
||||
else edge_color[i][j][i-1][j]=map[i][j];
|
||||
}
|
||||
if(i<10)
|
||||
{
|
||||
if(j==0||j==10||map[i+1][j]!=map[i+1][j+1]||map[i+1][j]==-1||map[i+1][j+1]==-1) edge_color[i][j][i+1][j]=-1;
|
||||
else edge_color[i][j][i+1][j]=map[i+1][j+1];
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
if(i==0||i==10||map[i][j]!=map[i+1][j]||map[i][j]==-1||map[i+1][j]==-1) edge_color[i][j][i][j-1]=-1;
|
||||
else edge_color[i][j][i][j-1]=map[i+1][j];
|
||||
}
|
||||
if(j<10)
|
||||
{
|
||||
if(i==0||i==10||map[i][j+1]!=map[i+1][j+1]||map[i][j+1]==-1||map[i+1][j+1]==-1) edge_color[i][j][i][j+1]=-1;
|
||||
else edge_color[i][j][i][j+1]=map[i][j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int update_distance(dot* start_point,int ID)
|
||||
{
|
||||
//Todo:
|
||||
//1. Get unpassable lines
|
||||
//2. Do a bfs
|
||||
//Note:
|
||||
//1. An edge label 400 or 500 means specially defined unpassable lines
|
||||
//2. This update process is only valid for a certain ID, i.e. the defined player
|
||||
unsigned int tmp_distance[15][15];
|
||||
bool in_queue[15][15];
|
||||
memset(tmp_distance,0xff,sizeof(tmp_distance));
|
||||
memset(in_queue,0,sizeof(in_queue));
|
||||
queue<dot*>* q=new queue<dot*>;
|
||||
q->push(start_point);
|
||||
tmp_distance[start_point->x][start_point->y]=0;
|
||||
while ((!q->empty()))
|
||||
{
|
||||
dot* tmp=q->front();
|
||||
q->pop();
|
||||
in_queue[tmp->x][tmp->y]=false;
|
||||
if((tmp->x>0)&&(edge_color[tmp->x][tmp->y][tmp->x-1][tmp->y]==-1)&&(tmp_distance[tmp->x-1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x-1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x-1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x-1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x-1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->x<10)&&(edge_color[tmp->x][tmp->y][tmp->x+1][tmp->y]==-1)&&(tmp_distance[tmp->x+1][tmp->y]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x+1][tmp->y]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x+1;
|
||||
tmp2->y=tmp->y;
|
||||
if(!in_queue[tmp->x+1][tmp->y])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x+1][tmp->y]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y>0)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y-1]==-1)&&(tmp_distance[tmp->x][tmp->y-1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y-1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y-1;
|
||||
if(!in_queue[tmp->x][tmp->y-1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y-1]=true;
|
||||
}
|
||||
}
|
||||
if((tmp->y<10)&&(edge_color[tmp->x][tmp->y][tmp->x][tmp->y+1]==-1)&&(tmp_distance[tmp->x][tmp->y+1]>tmp_distance[tmp->x][tmp->y]+1))
|
||||
{
|
||||
tmp_distance[tmp->x][tmp->y+1]=tmp_distance[tmp->x][tmp->y]+1;
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=tmp->x;
|
||||
tmp2->y=tmp->y+1;
|
||||
if(!in_queue[tmp->x][tmp->y+1])
|
||||
{
|
||||
q->push(tmp2);
|
||||
in_queue[tmp->x][tmp->y+1]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=10;i++) for(int j=0;j<=10;j++) relative_distance[ID][start_point->x][start_point->y][i][j]=tmp_distance[i][j];
|
||||
return -1;
|
||||
}
|
||||
int calculate_area(dot** x,int dot_num)
|
||||
{
|
||||
int i,j,k,s=1;
|
||||
int ans=0;
|
||||
for(i=1;i<=dot_num-1;i++)
|
||||
if(x[i]->x==x[dot_num]->x&&x[i]->y==x[dot_num]->y) s=i;
|
||||
for(i=1;i<=10;i++)
|
||||
for(j=1;j<=10;j++)
|
||||
{
|
||||
bool left=false;
|
||||
bool right=false;
|
||||
bool top=false;
|
||||
bool bottom=false;
|
||||
for(k=s+1;k<=dot_num;k++)
|
||||
{
|
||||
if(x[k-1]->x==x[k]->x&&x[k-1]->y==x[k]->y) continue;
|
||||
if(x[k-1]->x==x[k]->x)
|
||||
{
|
||||
if(x[k-1]->y<x[k]->y)
|
||||
{
|
||||
if(j==x[k]->y&&i>x[k]->x) top=true;
|
||||
if(j==x[k]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
if(x[k-1]->y>x[k]->y)
|
||||
{
|
||||
if(j==x[k-1]->y&&i>x[k]->x) top=true;
|
||||
if(j==x[k-1]->y&&i<=x[k]->x) bottom=true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(x[k-1]->y==x[k]->y)
|
||||
{
|
||||
if(x[k-1]->x<x[k]->x)
|
||||
{
|
||||
if(i==x[k]->x&&j>x[k]->y) left=true;
|
||||
if(i==x[k]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
if(x[k-1]->x>x[k]->x)
|
||||
{
|
||||
if(i==x[k-1]->x&&j>x[k]->y) left=true;
|
||||
if(i==x[k-1]->x&&j<=x[k]->y) right=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(left&&right&&top&&bottom&&-1==map[i][j]) ans++;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
inline int get_distance(int ID,dot* p1,dot* p2,double heuristic)
|
||||
{
|
||||
int tmp_distance=relative_distance[ID][p1->x][p1->y][p2->x][p2->y];
|
||||
double h_distance=(double)tmp_distance*heuristic;
|
||||
//if((*p1)==(*(game->players[ID]->position))&&(*p2)==(*(game->players[ID]->position))) return 0;
|
||||
if(p1->x==game->players[ID]->position->x&&p1->y==game->players[ID]->position->y&&p2->x==game->players[ID]->position->x&&p2->y==game->players[ID]->position->y) return 0;
|
||||
else return (floor(h_distance)+game->players[ID]->trappedleft);
|
||||
}
|
||||
int calculate_maximum_safe_enclosure(int ID,int road_id,double heuristic)
|
||||
{
|
||||
if((int)(relative_distance[ID][game->players[ID]->position->x][game->players[ID]->position->y][game->players[ID]->road[road_id]->x][game->players[ID]->road[road_id]->y])==-1) return;
|
||||
int tmp_num=0,max_length=INT_MAX;
|
||||
dot* tmp_road[300];
|
||||
for(int i=0;i<300;i++) tmp_road[i]=new dot;
|
||||
for(int i=road_id;i<game->players[ID]->num;i++) tmp_road[++tmp_num]=game->players[ID]->road[i];
|
||||
fout6<<"-----AI LOG------"<<endl;
|
||||
fout6<<"CURRENT POSITION: "<<"("<<game->players[ID]->position->x<<","<<game->players[ID]->position->y<<")"<<endl;
|
||||
for(int i=1;i<game->players[ID]->num;i++)
|
||||
{
|
||||
int tmp_min_length=INT_MAX;
|
||||
for(int j=0;j<4;j++)
|
||||
{
|
||||
if(j==ID) continue;
|
||||
int real_distance=get_distance(j,game->players[j]->position,game->players[ID]->road[i],heuristic);
|
||||
if(real_distance<tmp_min_length) tmp_min_length=real_distance;
|
||||
}
|
||||
if(tmp_min_length<max_length) max_length=tmp_min_length;
|
||||
}
|
||||
fout6<<"ESTIMATED TURN LEFT: "<<max_length<<endl;
|
||||
int maximum_area=-1;
|
||||
for(int i=(int)relative_distance[ID][game->players[ID]->position->x][game->players[ID]->position->y][game->players[ID]->road[1]->x][game->players[ID]->road[1]->y];i<=max_length;i++)
|
||||
{
|
||||
fout6<<"TESTING LENGTH: "<<i<<endl;
|
||||
exdot* s[300];
|
||||
dot* target=new dot;
|
||||
target=game->players[ID]->road[road_id];
|
||||
for(int j=0;j<300;j++) s[j]=new exdot;
|
||||
bool visited[15][15];
|
||||
memset(visited,0,sizeof(visited));
|
||||
int s_size=0;
|
||||
exdot* tmp=new exdot;
|
||||
tmp->x=game->players[ID]->position->x;
|
||||
tmp->y=game->players[ID]->position->y;
|
||||
tmp->meta[0]=0;
|
||||
s[s_size++]=tmp;
|
||||
visited[tmp->x][tmp->y]=true;
|
||||
fout6<<"DFS INITIALIZED"<<endl;
|
||||
while(s_size>0)
|
||||
{
|
||||
exdot* tmp1=new exdot;
|
||||
tmp1=s[s_size-1];
|
||||
if((s_size>i&&!(tmp1->x==target->x&&tmp1->y==target->y))||(s_size!=i+1&&tmp1->x==target->x&&tmp1->y==target->y))
|
||||
{
|
||||
//fout6<<"STACK OVERFLOW AT POINT ("<<tmp1->x<<","<<tmp1->y<<")"<<endl;
|
||||
s_size--;
|
||||
visited[tmp1->x][tmp1->y]=false;
|
||||
continue;
|
||||
}
|
||||
//fout6<<"APPROACHED POINT ("<<tmp1->x<<","<<tmp1->y<<")"<<endl;
|
||||
if(tmp1->x==target->x&&tmp1->y==target->y&&s_size==i+1)
|
||||
{
|
||||
fout6<<"TARGET APPROACHED"<<endl;
|
||||
dot* sp[300];
|
||||
for(int j=0;j<300;j++) sp[j]=new dot;
|
||||
for(int j=1;j<=tmp_num;j++) sp[j]=tmp_road[j];
|
||||
for(int j=0;j<s_size;j++)
|
||||
{
|
||||
dot* tmp2=new dot;
|
||||
tmp2->x=s[j]->x;
|
||||
tmp2->y=s[j]->y;
|
||||
sp[tmp_num+j+1]=tmp2;
|
||||
}
|
||||
fout6<<"CALCULATING AREA..."<<endl;
|
||||
int tmp_area=calculate_area(sp,tmp_num+s_size);
|
||||
fout6<<"EXPECTED AREA: "<<tmp_area<<endl;
|
||||
fout6<<"CURRENT MAXIMUM EXPECTED AREA: "<<maximum_area<<endl;
|
||||
if(tmp_area>maximum_area)
|
||||
{
|
||||
fout6<<"REPLACING MAXIMUM EXPECTED AREA... "<<endl;
|
||||
maximum_area=tmp_area;
|
||||
fout6<<"TRACING...
|
||||
for(int j=0;j<s_size;j++)
|
||||
{
|
||||
bestroad[j]->x=s[j-1]->x;
|
||||
bestroad[j]->y=s[j-1]->y;
|
||||
}
|
||||
}
|
||||
s_size--;
|
||||
visited[tmp1->x][tmp1->y]=false;
|
||||
}
|
||||
else if(tmp1->meta[0]==0)
|
||||
{
|
||||
tmp1->meta[0]++;
|
||||
if(tmp1->y<10&&edge_color[tmp1->x][tmp1->y][tmp1->x][tmp1->y+1]==-1&&!visited[tmp1->x][tmp1->y+1])
|
||||
{
|
||||
bool safe=true;
|
||||
for(int j=0;j<4;j++)
|
||||
{
|
||||
if(j!=now_id)
|
||||
{
|
||||
dot* p=new dot;
|
||||
p->x=tmp1->x;
|
||||
p->y=tmp1->y+1;
|
||||
int tmp_distance=get_distance(j,game->players[j]->position,p,heuristic);
|
||||
if(tmp_distance<i) safe=false;
|
||||
|
||||
}
|
||||
}
|
||||
if(safe)
|
||||
{
|
||||
exdot* tmp2=new exdot;
|
||||
tmp2->x=tmp1->x;
|
||||
tmp2->y=tmp1->y+1;
|
||||
tmp2->meta[0]=0;
|
||||
visited[tmp2->x][tmp2->y]=true;
|
||||
s[s_size++]=tmp2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tmp1->meta[0]==1)
|
||||
{
|
||||
tmp1->meta[0]++;
|
||||
if(tmp1->y>0&&edge_color[tmp1->x][tmp1->y][tmp1->x][tmp1->y-1]==-1&&!visited[tmp1->x][tmp1->y-1])
|
||||
{
|
||||
bool safe=true;
|
||||
for(int j=0;j<4;j++)
|
||||
{
|
||||
if(j!=now_id)
|
||||
{
|
||||
dot* p=new dot;
|
||||
p->x=tmp1->x;
|
||||
p->y=tmp1->y-1;
|
||||
int tmp_distance=get_distance(j,game->players[j]->position,p,heuristic);
|
||||
if(tmp_distance<i) safe=false;
|
||||
|
||||
}
|
||||
}
|
||||
if(safe)
|
||||
{
|
||||
exdot* tmp2=new exdot;
|
||||
tmp2->x=tmp1->x;
|
||||
tmp2->y=tmp1->y-1;
|
||||
tmp2->meta[0]=0;
|
||||
visited[tmp2->x][tmp2->y]=true;
|
||||
s[s_size++]=tmp2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tmp1->meta[0]==2)
|
||||
{
|
||||
tmp1->meta[0]++;
|
||||
if(tmp1->x<10&&edge_color[tmp1->x][tmp1->y][tmp1->x+1][tmp1->y]==-1&&!visited[tmp1->x+1][tmp1->y])
|
||||
{
|
||||
bool safe=true;
|
||||
for(int j=0;j<4;j++)
|
||||
{
|
||||
if(j!=now_id)
|
||||
{
|
||||
dot* p=new dot;
|
||||
p->x=tmp1->x+1;
|
||||
p->y=tmp1->y;
|
||||
int tmp_distance=get_distance(j,game->players[j]->position,p,heuristic);
|
||||
if(tmp_distance<i) safe=false;
|
||||
|
||||
}
|
||||
}
|
||||
if(safe)
|
||||
{
|
||||
exdot* tmp2=new exdot;
|
||||
tmp2->x=tmp1->x+1;
|
||||
tmp2->y=tmp1->y;
|
||||
tmp2->meta[0]=0;
|
||||
visited[tmp2->x][tmp2->y]=true;
|
||||
s[s_size++]=tmp2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tmp1->meta[0]==3)
|
||||
{
|
||||
tmp1->meta[0]++;
|
||||
if(tmp1->x>0&&edge_color[tmp1->x][tmp1->y][tmp1->x-1][tmp1->y]==-1&&!visited[tmp1->x-1][tmp1->y])
|
||||
{
|
||||
bool safe=true;
|
||||
for(int j=0;j<4;j++)
|
||||
{
|
||||
if(j!=now_id)
|
||||
{
|
||||
dot* p=new dot;
|
||||
p->x=tmp1->x-1;
|
||||
p->y=tmp1->y;
|
||||
int tmp_distance=get_distance(j,game->players[j]->position,p,heuristic);
|
||||
if(tmp_distance<i) safe=false;
|
||||
|
||||
}
|
||||
}
|
||||
if(safe)
|
||||
{
|
||||
exdot* tmp2=new exdot;
|
||||
tmp2->x=tmp1->x-1;
|
||||
tmp2->y=tmp1->y;
|
||||
tmp2->meta[0]=0;
|
||||
visited[tmp2->x][tmp2->y]=true;
|
||||
s[s_size++]=tmp2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tmp1->meta[0]==4)
|
||||
{
|
||||
visited[tmp1->x][tmp1->y]=false;
|
||||
s_size--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return maximum_area;
|
||||
}
|
||||
void isolate_bind()
|
||||
{
|
||||
for(int j=1;j<=bind_total;j++)
|
||||
{
|
||||
if(bind[j]->x>0) edge_color[bind[j]->x-1][bind[j]->y][bind[j]->x][bind[j]->y]=edge_color[bind[j]->x][bind[j]->y][bind[j]->x-1][bind[j]->y]=500;
|
||||
if(bind[j]->x<=10) edge_color[bind[j]->x+1][bind[j]->y][bind[j]->x][bind[j]->y]=edge_color[bind[j]->x][bind[j]->y][bind[j]->x+1][bind[j]->y]=500;
|
||||
if(bind[j]->y>0) edge_color[bind[j]->x][bind[j]->y+1][bind[j]->x][bind[j]->y]=edge_color[bind[j]->x][bind[j]->y][bind[j]->x][bind[j]->y-1]=500;
|
||||
if(bind[j]->y<=10) edge_color[bind[j]->x][bind[j]->y-1][bind[j]->x][bind[j]->y]=edge_color[bind[j]->x][bind[j]->y][bind[j]->x][bind[j]->y+1]=500;
|
||||
}
|
||||
}
|
||||
void brain()
|
||||
{
|
||||
dot* tmp_bestroad[300];
|
||||
for(int i=0;i<300;i++) tmp_bestroad[i]=new dot;
|
||||
update_edge_status();
|
||||
int original_edge_color[15][15][15][15];
|
||||
memcpy(original_edge_color,edge_color,sizeof(original_edge_color));
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
memcpy(edge_color,original_edge_color,sizeof(edge_color));
|
||||
isolate_bind();
|
||||
if(game->players[i]->state==state_down)
|
||||
{
|
||||
for(int j=1;j<game->players[i]->num;j++)
|
||||
{
|
||||
dot* p1=new dot;
|
||||
dot* p2=new dot;
|
||||
p1=game->players[i]->road[j];
|
||||
p2=game->players[i]->road[j+1];
|
||||
edge_color[p1->x][p1->y][p2->x][p2->y]=edge_color[p2->x][p2->y][p1->x][p1->y]=400;
|
||||
}
|
||||
}
|
||||
else if(game->players[i]->state==state_up)
|
||||
{
|
||||
//Downward Road
|
||||
for(int j=0;j<10;j++) for(int k=0;k<=10;k++) if((edge_color[j][k][j+1][k]/100)==i) edge_color[j][k][j+1][k]=-1;
|
||||
//Upward Road
|
||||
for(int j=1;j<=10;j++) for(int k=0;k<=10;k++) if((edge_color[j][k][j-1][k]/100)==i) edge_color[j][k][j-1][k]=-1;
|
||||
//Rightward Road
|
||||
for(int j=0;j<=10;j++) for(int k=0;k<10;k++) if((edge_color[j][k][j][k+1]/100)==i) edge_color[j][k][j][k+1]=-1;
|
||||
//Leftward Road
|
||||
for(int j=0;j<=10;j++) for(int k=1;k<=10;k++) if((edge_color[j][k][j][k-1]/100)==i) edge_color[j][k][j][k-1]=-1;
|
||||
}
|
||||
update_distance(game->players[i]->position,i);
|
||||
}
|
||||
memcpy(edge_color,original_edge_color,sizeof(edge_color));
|
||||
if(game->players[now_id]->state==state_down)
|
||||
{
|
||||
isolate_bind();
|
||||
for(int j=1;j<game->players[now_id]->num;j++)
|
||||
{
|
||||
dot* p1=new dot;
|
||||
dot* p2=new dot;
|
||||
p1=game->players[now_id]->road[j];
|
||||
p2=game->players[now_id]->road[j+1];
|
||||
edge_color[p1->x][p1->y][p2->x][p2->y]=edge_color[p2->x][p2->y][p1->x][p1->y]=400;
|
||||
}
|
||||
for(int j=1;j<game->players[now_id]->num;j++) calculate_maximum_safe_enclosure(now_id,j,1);
|
||||
}
|
||||
memcpy(edge_color,original_edge_color,sizeof(edge_color));
|
||||
int now_x[4],now_y[4];
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
now_x[i]=game->players[i]->position->x;
|
||||
now_y[i]=game->players[i]->position->y;
|
||||
}
|
||||
//Finite State Machine
|
||||
/*
|
||||
if(mode==mode_start)
|
||||
{
|
||||
mode=mode_right;
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
if(now_x[now_id]==10&&now_y[now_id]==10) mode=mode_up;
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
if(now_x[now_id]==0&&now_y[now_id]==10) mode=mode_left;
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
if(now_x[now_id]==0&&now_y[now_id]==0) mode=mode_down;
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
if(now_x[now_id]==10&&now_y[now_id]==0) mode=mode_halt;
|
||||
}
|
||||
//Output Area
|
||||
if(mode==mode_right&&now_y[now_id]==0)
|
||||
{
|
||||
generate_output(0,1,1);
|
||||
}
|
||||
else if(mode==mode_right)
|
||||
{
|
||||
generate_output(0,1,0);
|
||||
}
|
||||
else if(mode==mode_up)
|
||||
{
|
||||
generate_output(-1,0,0);
|
||||
}
|
||||
else if(mode==mode_left)
|
||||
{
|
||||
generate_output(0,-1,0);
|
||||
}
|
||||
else if(mode==mode_down)
|
||||
{
|
||||
generate_output(1,0,0);
|
||||
}
|
||||
else if(mode==mode_halt)
|
||||
{
|
||||
generate_output(0,0,0);
|
||||
}
|
||||
*/
|
||||
//Debug Output
|
||||
fout1<<"---MAP---"<<endl;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
//This statement has been fixed to adapt EnclosureJudge
|
||||
for(int j=1;j<=10;j++) fout1<<setiosflags(ios::fixed)<<setw(4)<<map[j][i]; //map[i][j]
|
||||
fout1<<endl;
|
||||
}
|
||||
fout1<<"---END---"<<endl;
|
||||
fout1<<endl;
|
||||
fout2<<"---VERTICAL ROAD---"<<endl;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++) fout2<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j][i+1];
|
||||
fout2<<endl;
|
||||
}
|
||||
fout2<<"--------END--------"<<endl;
|
||||
fout2<<endl;
|
||||
fout3<<"---HORIZONTAL ROAD---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<10;j++) fout3<<setiosflags(ios::fixed)<<setw(4)<<edge_color[j][i][j+1][i];
|
||||
fout3<<endl;
|
||||
}
|
||||
fout3<<"---------END---------"<<endl;
|
||||
fout3<<endl;
|
||||
fout4<<"---RELATIVE DISTANCE---"<<endl;
|
||||
for(int i=0;i<=10;i++)
|
||||
{
|
||||
for(int j=0;j<=10;j++)
|
||||
{
|
||||
int rd=relative_distance[now_id][now_x[now_id]][now_y[now_id]][j][i];
|
||||
fout4<<setiosflags(ios::fixed)<<setw(4)<<rd;
|
||||
}
|
||||
fout4<<endl;
|
||||
}
|
||||
fout4<<"----------END----------"<<endl;
|
||||
fout4<<endl;
|
||||
return;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
for(int i=0;i<4;i++) now[i]=100*i;
|
||||
for(int j=0;j<300;j++) bestroad[j]=new dot;
|
||||
for(int i=0;i<200;i++) bind[i]=new dot;
|
||||
string label;
|
||||
cin>>label;
|
||||
cin>>now_id;
|
||||
cout<<"[POS] 10 0"<<endl;
|
||||
memset(map,0xff,sizeof(map));
|
||||
memset(edge_color,0xff,sizeof(edge_color));
|
||||
memset(relative_distance,0xff,sizeof(relative_distance));
|
||||
bool started=false; //Update: variable name changed from visited to started
|
||||
while (true)
|
||||
{
|
||||
cin>>label;
|
||||
for(int i=0;i<=3;i++)
|
||||
{
|
||||
cin>>x[i]>>y[i]>>state[i]>>trappedleft[i]>>scoredecline[i];
|
||||
}
|
||||
if(!started)
|
||||
{
|
||||
started=true;
|
||||
//game=new enclosure(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
|
||||
game=new enclosure(x,y);
|
||||
}
|
||||
game->pass(0,x[0],y[0],state[0]);
|
||||
game->pass(1,x[1],y[1],state[1]);
|
||||
game->pass(2,x[2],y[2],state[2]);
|
||||
game->pass(3,x[3],y[3],state[3]);
|
||||
game->make();
|
||||
cin>>bind_total;
|
||||
for(int i=1;i<=bind_total;i++)
|
||||
{
|
||||
cin>>bind[i]->x>>bind[i]->y>>timeleft[i];
|
||||
}
|
||||
brain();
|
||||
}
|
||||
}
|
BIN
orz_0_6_8.exe
BIN
orz_0_6_8.exe
Binary file not shown.
Loading…
Reference in New Issue