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的 ...
随机推荐
- Android 系统(64)---Android中m、mm、mmm、mma、mmma的区别【转】
本文转载自:https://blog.csdn.net/zhangbijun1230/article/details/80196379 Android中m.mm.mmm.mma.mmma的区别 m ...
- git如何修改用户名和邮箱名?
答: 使用git config --global --edit即可进行修改
- [转] Java中的final、static、this、super
final 关键字 final关键字主要用在三个地方:变量.方法.类. 对于一个final变量,如果是基本数据类型的变量,则其数值一旦在初始化之后便不能更改:如果是引用类型的变量,则在对其初始化之后便 ...
- [转] Java 基础
1. 面向对象和面向过程的区别 面向过程 面向对象 2. Java 语言有哪些特点 3. 关于 JVM JDK 和 JRE 最详细通俗的解答 JVM JDK 和 JRE 4. Oracle JDK 和 ...
- 到底什么是 ROI Pooling Layer ???
到底什么是 ROI Pooling Layer ??? 只知道 faster rcnn 中有 ROI pooling, 而且其他很多算法也都有用这个layer 来做一些事情,如:SINT,检测的文章等 ...
- The issus in Age Progression/Regression by Conditional Adversarial Autoencoder (CAAE)
The issus in Age Progression/Regression by Conditional Adversarial Autoencoder (CAAE) Today I tried ...
- (转载)MySQL用命令行复制表的方法
mysql中用命令行复制表结构的方法主要有一下几种: 1.只复制表结构到新表 ; 或 CREATE TABLE 新表 LIKE 旧表 ; 注意上面两种方式,前一种方式是不会复制时的主键类型和自增方式是 ...
- Java基础【冒泡、选择排序、二分查找】
冒泡排序的思路就是前一个和后一个进行比较,如果大的就交换位置 大的数字后浮 如 12 8 5 31 第一轮 8 5 12 31 第二轮 5 8 ...
- Shiro学习笔记五(Shiro标签,及通配符)
1.首先是导入标签库 <%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %> ...
- Kubernetes工作流之Pods一
This page provides an overview of Pod, the smallest deployable object in the Kubernetes object model ...