算法: 模拟
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; //方向数组
const int N = 20;
char g[N][N];
PII c, f; int dc, df;
int ans;
inline void init()
{
for(int i = 1; i <= 10; i++)
for(int j = 1; j <= 10; j++)
{
cin >> g[i][j];
if(g[i][j] == 'C') c = {i, j};
if(g[i][j] == 'F') f = {i, j};
}
}
inline bool valid(PII a)
{
return (a.x >= 1 && a.x <= 10 && a.y >= 1 && a.y <= 10 && g[a.x][a.y] != '*');
}
inline void work()
{
while(c.x != f.x || c.y != f.y)
{
ans ++;
c.x += dx[dc], c.y += dy[dc];
f.x += dx[df], f.y += dy[df];
if(!valid(c)) c.x -= dx[dc], c.y -= dy[dc], dc ++, dc %= 4; // 方向++并且模4,实现顺时针90度转弯.(24J组T2qwq)
if(!valid(f)) f.x -= dx[df], f.y -= dy[df], df ++, df %= 4;
if(c.x == f.x && c.y == f.y) break;
else if(ans > 160000) {ans = 0; break;} // 若遍历了一遍所有状态还没抓到就永远抓不到.
}
}
int main()
{
//freopen("input.in", "r", stdin);
//freopen("input.out", "w", stdout);
init();
work();
cout << ans << endl;
return 0;
}