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 ...
随机推荐
- android 高德地图出现【定位失败key鉴权失败】
如题:android 高德地图出现[定位失败key鉴权失败] 原因:使用的是debug模式下的SHA1,发布的版本正确获取SHA1的方式见: 方法二使用 keytool(jdk自带工具),按照如下步骤 ...
- Log4j2 配置笔记(Eclipse+maven+SpringMVC)
Log4j2相关介绍可以百度看下,这里只注重配置Log4j2 能够马上跑起来: 1.pom.xml文件中添加Log4j2的相关Maven配置信息 <!-- log4j2 --> <d ...
- C#--简单的串口通信程序
前几天做毕业设计,其中要用到串口和下位机进行通信,于是自己捣鼓了一个简单的串口通信程序. 在做通信之前要先弄一个SerialPort组件出来,当然也可以通过程序来创建.本次设计中采用的是拖的winfo ...
- 【BZOJ】【1406】【AHOI2007】密码箱
数论 Orz iwtwiioi 果然数论很捉鸡>_>完全不知道怎么下手 $$x^2 \equiv 1 \pmod n \rightarrow (x+1)*(x-1)=k*n $$ 所以,我 ...
- JS控制图片拖动 放大 缩小 旋转 支持滚轮放大缩小 IE有效
<html> <head> <title>图片拖动,放大,缩小,转向</title> <script type="text/ja ...
- 关于Web与JS
Web包含的范围比较广, JS只是代码逻辑而已. Web比如HTTP Message, SOAP Message, 浏览器流程,工具等. 不仅仅是代码.
- Java NIO 与 基于reactor设计模式的事件处理模型
Java NIO非堵塞应用通常适用用在I/O读写等方面,我们知道,系统运行的性能瓶颈通常在I/O读写,包括对端口和文件的操作上,过去,在打开一个I/O通道后,read()将一直等待在端口一边读取字节内 ...
- asp.net各种类型视频播放代码(全)
1.avi格式 代码片断如下: <object id="video" width="400" height="200" border= ...
- HDU 1403 Longest Common Substring(后缀数组,最长公共子串)
hdu题目 poj题目 参考了 罗穗骞的论文<后缀数组——处理字符串的有力工具> 题意:求两个序列的最长公共子串 思路:后缀数组经典题目之一(模版题) //后缀数组sa:将s的n个后缀从小 ...
- SGU 107
107. 987654321 problem time limit per test: 0.25 sec. memory limit per test: 4096 KB For given numbe ...