p1518 The Tamworth Two
#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 ;
}
p1518 The Tamworth Two的更多相关文章
- 洛谷P1518 两只塔姆沃斯牛 The Tamworth Two
P1518 两只塔姆沃斯牛 The Tamworth Two 109通过 184提交 题目提供者该用户不存在 标签USACO 难度普及+/提高 提交 讨论 题解 最新讨论 求数据 题目背景 题目描 ...
- luogu P1518 两只塔姆沃斯牛 The Tamworth Two
luogu P1518 两只塔姆沃斯牛 The Tamworth Two 题目描述 两只牛逃跑到了森林里.农夫John开始用他的专家技术追捕这两头牛.你的任务是模拟他们的行为(牛和John). 追击在 ...
- 洛谷 P1518 两只塔姆沃斯牛 The Tamworth Two
P1518 两只塔姆沃斯牛 The Tamworth Two 题目背景 题目描述 两只牛逃跑到了森林里.农夫John开始用他的专家技术追捕这两头牛.你的任务是模拟他们的行为(牛和John). 追击在1 ...
- P1518 [USACO2.4]两只塔姆沃斯牛 The Tamworth Two
// Problem: P1518 [USACO2.4]两只塔姆沃斯牛 The Tamworth Two // Contest: Luogu // URL: https://www.luogu.com ...
- 洛谷——P1518 两只塔姆沃斯牛 The Tamworth Two
https://www.luogu.org/problem/show?pid=1518 题目背景 题目描述 两只牛逃跑到了森林里.农夫John开始用他的专家技术追捕这两头牛.你的任务是模拟他们的行为( ...
- P1518 两只塔姆沃斯牛 The Tamworth Two(简单的搜索题)
题目描述 两只牛逃跑到了森林里.农夫John开始用他的专家技术追捕这两头牛.你的任务是模拟他们的行为(牛和John). 追击在10x10的平面网格内进行.一个格子可以是: 一个障碍物, 两头牛(它们总 ...
- 洛谷 P1518 两只塔姆沃斯牛
P1518 两只塔姆沃斯牛 The Tamworth Two 简单的模拟题,代码量不大. 他们走的路线取决于障碍物,可以把边界也看成障碍物,遇到就转,枚举次,因为100 * 100 * 4,只有4个可 ...
- USACO2.4 The Tamworth Two[模拟]
题目描述 两只牛逃跑到了森林里.农夫John开始用他的专家技术追捕这两头牛.你的任务是模拟他们的行为(牛和John). 追击在10x10的平面网格内进行.一个格子可以是: 一个障碍物, 两头牛(它们总 ...
- 【USACO 2.4】The Tamworth Two
题意:C代表cows,F代表farmer,一开始都向北,每分钟前进1步,如果前方不能走,则这分钟顺时针转90°,问多少步能相遇,或者是否不可能相遇,10*10的地图. 题解:dfs,记录状态,C和F的 ...
随机推荐
- 我的QML
1.键盘加Text import QtQuick 2.7 import QtGraphicalEffects 1.0 Rectangle{ width:; height:; color:"# ...
- JUnit Parametrized Tests
Junit allows us to create parametrized tests. Parametrized test class has to be annotated with the @ ...
- 关于BOARD_SYSTEMIMAGE_PARTITION_SIZE【转】
本文转载自:https://blog.csdn.net/ttxgz/article/details/7542380 1. 系统需要,把需要预置在系统的所有apk放在目录 device/softwinn ...
- 【安装】Redis4.0.10在Linux环境搭建
1.下载Redis后上传到指定目录 2.解压 tar -zxvf redis-4.0.10.tar.gz 3.进入加压后的目录并编译 cd redis-4.0.10 make 4.进入src目录安装 ...
- SQL Server (MSSQLSERVER) 服务因 2148081668 服务性错误而停止。
https://zhidao.baidu.com/question/151448005.html 具体步骤: 运行-> 输入:“services.msc” ->找到 “SQL Server ...
- 题解——Codeforces Round #508 (Div. 2) T1 (模拟)
依照题意暴力模拟即可A掉 #include <cstdio> #include <algorithm> #include <cstring> #include &l ...
- 论文笔记之:Learning Cross-Modal Deep Representations for Robust Pedestrian Detection
Learning Cross-Modal Deep Representations for Robust Pedestrian Detection 2017-04-11 19:40:22 Moti ...
- AndroidStudio Gradle下载速度慢解决方法
1.在软件里点开工程文件下的 build.gradle 2..在 buildscript 和 allprojects 的 repositories 中分别注释掉 jcenter() 3.在 build ...
- 今天就整一个bug了
BeanPostProcessor加载次序及其对Bean造成的影响分析 SSM整合出现not found for dependency: expected at least 1 bean which ...
- Java String 函数常用操作 & format() 格式化输出,代码详解
package _String_; import java.util.*; import java.math.*; import java.lang.*; public class _Strings ...