/*
ID: Jang Lawrence
PROG: ttwo
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#define mp make_pair
using namespace std;
typedef long long lng;
typedef pair<int, int> pii;
char m[11][11];
bool is[11][11];
int dir[][2]={-1,0,0,1,1,0,0,-1};
bool can(int x,int y)
{
return x>=0&&x<10&&y>=0&&y<10&&is[x][y];
}
struct role
{
int x,y,d;
void move()
{
int kx=x+dir[d][0],ky=y+dir[d][1];
if(can(kx,ky)) x=kx,y=ky;
else
d=(d+1)%4;
}
}f,c;
bool g()
{
return f.x==c.x&&f.y==c.y;
}
int main()
{
#ifndef DEBUG
freopen("ttwo.in","r",stdin);
freopen("ttwo.out","w",stdout);
#endif
for(int i=0;i<10;++i)
{
for(int j=0;j<10;++j)
{m[i][j]=getchar();
if(m[i][j]=='*') is[i][j]=0;
else is[i][j]=1;
if(m[i][j]=='F')
f.x=i,f.y=j,f.d=0;
else
if(m[i][j]=='C')
c.x=i,c.y=j,c.d=0;
}
getchar();
}
int res=0;
while(1)
{
f.move();
c.move();
res++;
if(g()) break;
if(res>160000)
{
res=0;
break;
}
}
printf("%d\n",res);
return 0;
}
usaco:The Tamworth Two
最新推荐文章于 2025-06-30 11:49:18 发布