ACM题目:庙宇逃亡
的有关信息介绍如下:
#include前或 #include #include using namespace std; struct node { int time; int turn; }comm[51]; char mb[16][16]; int step1[4]={-1,1,0,0}; int step2[4]={0,0,-1,1}; int f(char ch) { switch(ch) { case 's': return 0; case 'x': return 1; case 'z': return 2; case 'y': return 3; } } int cmp(const void * _a,const void * _b) { struct node * a = (struct node *)_a; struct node * b = (struct node *)_b; return a->time-b->time; } void init(int n,int m,int &s,int &k) { int i,j; char ch; for(i=0;i=n||nowx+step1[face]<0||nowy+step2[face]>=m||nowy+step2[face]<0||mb[nowx+step1[face]][nowy+step2[face]]=='X'||mb[nowx+step1[face]][nowy+step2[face]]=='x') { printf("Game over!\n%d %d %d\悄桐n",nowx,nowy,score); return; } else { nowx+=step1[face]; nowy+=step2[face]; ++score; } } face=comm[i].turn; now=comm[i].time; } } printf("You win!\n%d %d %d\n",nowx,nowy,score); } int main() { int m,n; int s,k; while(scanf("%d %d"启悔坦,&n,&m)!=EOF&&m&&n) { init(n,m,s,k); work(n,m,s,k+1); } return 0; }