#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF,mod=;
char ch[SZ][SZ];
bool vst[SZ][SZ][][SZ][SZ][];
int dx[]={-,,,},dy[]={,,,-}; int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
for(int i=;i<=;++i)cin>>ch[i]+;
int fx,fy,cx,cy;
for(int i=;i<=;++i)
{
for(int j=;j<=;++j)
{
if(ch[i][j]=='F')fx=i,fy=j;
if(ch[i][j]=='C')cx=i,cy=j;
}
}
vst[fx][fy][][cx][cy][]=;
int dc=,df=;
int time=;
//cout<<fx<<" "<<fy<<" "<<cx<<" "<<cy<<endl;
for(;;)
{
int nfx=fx+dx[df],nfy=fy+dy[df];
int ncx=cx+dx[dc],ncy=cy+dy[dc];
if(nfx>=&&nfx<=&&nfy>=&&nfy<=&&ch[nfx][nfy]!='*')
{
fx=nfx,fy=nfy;
}
else df=(df+)%;
if(ncx>=&&ncx<=&&ncy>=&&ncy<=&&ch[ncx][ncy]!='*')
{
cx=ncx,cy=ncy;
}
else dc=(dc+)%;
++time;
if(fx==cx&&fy==cy)
{
cout<<time<<endl;
break;
}
if(vst[fx][fy][df][cx][cy][dc]==)
{//cout<<fx<<" "<<fy<<" "<<cx<<" "<<cy<<endl;
cout<<<<endl;
break;
}
vst[fx][fy][df][cx][cy][dc]=;
}
}
return ;
}

最新文章

  1. usb驱动开发14之设备生命线
  2. 单例(C#版)
  3. Leetcode: Insert Delete GetRandom O(1) - Duplicates allowed
  4. fragment (1)简单示例:定义,界面配置,fragment之间的跳转
  5. 使用 JAX-RS 简化 REST 应用开发
  6. 漫谈C语言及如何学习C语言
  7. BZOJ 3993 [SDOI 2015] 星际战争 解题报告
  8. Flume+LOG4J+Kafka
  9. 谈谈渲染,玩玩nginx——前后端分离,转发请求到Tomcat的尝试
  10. iOS 友盟推送,应用内推送启动图推送闪动黑屏,插屏推送方法报错
  11. Bilateral Filter
  12. 10 - JavaSE之网络编程
  13. NOIP2017感悟
  14. 执行发送邮件Send方法时,报错:邮箱不可用。 服务器响应为: 5.7.1 Unable to relay for xxx@xxx.com
  15. python &#39;%r&#39;或者&#39;{!r}&#39;的意思
  16. [三边定位] C# 演示程序
  17. non-ZenoAndAcceptingLocation
  18. html5-figure和figcaption元素
  19. Shell函数和数组
  20. [USACO19FEB]Moorio Kart

热门文章

  1. Item的anchors属性
  2. UVALive 7501 Business Cycle(二分)题解
  3. c# 之继承、封装、多态
  4. P3211 [HNOI2011]XOR和路径
  5. Yarn 的日志聚集功能配置使用
  6. java核心问题总结
  7. Ubuntu 安装 matplotlib
  8. 无法启动此程序,因为计算机中丢失api-ms-win-crt-runtime-|1-1-0.dll
  9. 使用explain来分析SQL语句实现优化SQL语句
  10. python类的成员