USACO Section 2.4: The Tamworth Two
这题我是用蒙的方法来弄出最后的不能碰到的条件的(用1000试了下account跳出条件),结果竟然还过了,不过网上有精准的求出这个碰不到的条件,farm的状态为10*10*4 = 400,cow的状态也一样,所以应为160000,不过要AC这题我用的1000也行。。
/*
ID: yingzho1
LANG: C++
TASK: ttwo
*/
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <stdio.h>
#include <queue>
#include <cstring>
#include <cmath>
using namespace std;
ifstream fin("ttwo.in");
ofstream fout("ttwo.out");
][];
], farm[];
][] = {{-, }, {, }, {, }, {, -}};
bool noobstacle(int x, int y) {
|| x >= || y < || y >= ) return false;
if (board[x][y] == '*') return false;
return true;
}
int main()
{
; i < ; i++) {
; j < ; j++) {
fin >> board[i][j];
if (board[i][j] == 'C') {
board[i][j] = '.';
cow[] = i, cow[] = j;
}
if (board[i][j] == 'F') {
board[i][j] = '.';
farm[] = i, farm[] = j;
}
}
}
;
int cowdir, farmdir;
cowdir = farmdir = ;
] != farm[] || cow[] != farm[]) {
account++;
]+dir[farmdir][], farm[]+dir[farmdir][])) {
farm[] += dir[farmdir][];
farm[] += dir[farmdir][];
}
) % ;
]+dir[cowdir][], cow[]+dir[cowdir][])) {
cow[] += dir[cowdir][];
cow[] += dir[cowdir][];
}
) % ;
//cout << account << endl;
) {
fout << << endl;
;
}
}
fout << account << endl;
;
}
USACO Section 2.4: The Tamworth Two的更多相关文章
- USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)
usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...
- USACO Section 3.3: Riding the Fences
典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...
- USACO Section 3.3 Camlot(BFS)
BFS.先算出棋盘上每个点到各个点knight需要的步数:然后枚举所有点,其中再枚举king是自己到的还是knight带它去的(假如是knight带它的,枚举king周围的2格(网上都这么说,似乎是个 ...
- [IOI1996] USACO Section 5.3 Network of Schools(强连通分量)
nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. --------- ...
- USACO Section 5.3 Big Barn(dp)
USACO前面好像有类似的题目..dp(i,j)=min(dp(i+1,j),dp(i+1,j+1),dp(i,j+1))+1 (坐标(i,j)处无tree;有tree自然dp(i,j)=0) .d ...
- USACO Section 1.3 Prime Cryptarithm 解题报告
题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...
- USACO Section 1.1 Your Ride Is Here 解题报告
题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...
- USACO Section 1.1-1 Your Ride Is Here
USACO 1.1-1 Your Ride Is Here 你的飞碟在这儿 众所周知,在每一个彗星后都有一只UFO.这些UFO时常来收集地球上的忠诚支持者.不幸的是,他们的飞碟每次出行都只能带上一组支 ...
- USACO section 1.1 C++题解
USACO section1.1:DONE 2017.03.03 TEXT Submitting Solutions DONE 2017.03.04 PROB Your Ride Is Here [A ...
随机推荐
- 或许你不知道:ArrayList
ArrayList 底层以一个transient 线性数组来存储数据,它提供了无参构造方法,和有参构造方法,用户可以通过有参构造方法来初始化长度.如果不传参数,则默认调用无参构造器,数组默认长度为10 ...
- Careercup - Microsoft面试题 - 5204967652589568
2014-05-11 23:57 题目链接 原题: identical balls. one ball measurements ........ dead easy. 题目:9个看起来一样的球,其中 ...
- android 通过AlarmManager实现守护进程
场景:在app崩溃或手动退出或静默安装后能够自动重启应用activity 前提:得到系统签名 platform.pk8.platform.x509.pem及signapk.jar 三个文件缺一不可(系 ...
- 【Evaluate Reverse Polish Notation】cpp
题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are + ...
- Jenkins-测试自动化环境搭建(Python+RobotFramework+selenium)
下载插件: Python:https://wiki.jenkins-ci.org/display/JENKINS/Python+Plugin RobotFramework:https://wiki.j ...
- django构建blog--建立数据库部分+admin部分(eclipse+pydev)
本文介绍的是在eclipse+pydev 平台下,利用django 搭建blog的第1部分:建立数据库+admin部分 步骤一:创建myweb项目+blog应用 1. Eclipse下新建一个djan ...
- 01.Hibernate入门
前言:本文用一个简单的Hibernate应用程序例子来引领初学者入门,让初学者对Hibernate的使用有一个大致的认识.本文例子使用了MySQL数据库.Maven管理工具.Eclipse开发工具,创 ...
- Leetcode#146 LRU Cache
原题地址 以前Leetcode的测试数据比较弱,单纯用链表做也能过,现在就不行了,大数据会超时.通常大家都是用map+双向链表做的. 我曾经尝试用C++的list容器来写,后来发现map没法保存lis ...
- Slim - 超轻量级PHP Restful API构建框架
下载源码包: http://www.slimframework.com/ 基于Slim的Restful API Sample: <?php require '/darjuan/Slim/Slim ...
- HDOJ 1466 计算直线的交点数
将n 条直线排成一个序列,直线2和直线1最多只有一个交点,直线3和直线1,2最多有两个交点,......,直线n 和其他n-1条直线最多有n-1个交点.由此得出n条直线互不平行且无三线共点的最多交点数 ...