POJ 3278 对数轴进行一维bfsCatch That CowTime Limit:2000MSMemory Limit:65536KTotal Submissions:52161Accepted:16355DescriptionFarmer John has been informed of....
分类:
其他好文 时间:
2015-03-13 10:47:24
阅读次数:
122
题意:给出两个点代表人和牛的位置,人的运动方式有三种,牛原地不用,问人赶到牛的位置的最快速度;key:刚开始找规律,其实规律都没规律,六组数据都过了那个碰巧。用bfs,搜到牛的位置结束,并返回步数(每个操作算一步)。注意牛可在人的左右边,要分开两种情况。#include #include #incl...
分类:
其他好文 时间:
2015-01-30 17:38:08
阅读次数:
158
抓住那头牛(POJ3278)农夫知道一头牛的位置,想要抓住它。农夫和牛都位于数轴上,农夫起始位于点N(0 2 #include 3 #include 4 using namespace std; 5 #define MAX 100000 6 struct Step 7 { 8 int xx...
分类:
其他好文 时间:
2015-01-17 19:29:49
阅读次数:
121
题目链接:http://poj.org/problem?id=3278分析:广搜,每次三种情况枚举一下,太水不多说了。#include #include #include #include #include #include #include #include #include #include #...
分类:
其他好文 时间:
2014-12-16 18:49:17
阅读次数:
153
Catch That CowTime Limit:2000MSMemory Limit:65536KDescriptionFarmer John has been informed of the location of a fugitive(逃亡的;难以捉摸的;短...
分类:
其他好文 时间:
2014-11-24 17:10:33
阅读次数:
216
题目地址:Catch That Cow题目大意: 一位农夫追赶一头牛,题目给出农夫和牛的坐标分别为N,K。农夫可以通过坐标的加一或减一也可以坐标乘以2。问你最少多少步到达牛的坐标。解题思路; 简单BFS。代码: 1 #include 2 #include 3 #include 4 #incl...
分类:
其他好文 时间:
2014-08-04 20:52:56
阅读次数:
215
数组必须开大点#include #include #include #include using
namespace std;struct node{ int x,ans;}q[1000005];int jx[]={-1,1};int n,k;int
map[1000005],v[100000...
分类:
其他好文 时间:
2014-06-08 20:48:03
阅读次数:
319
Catch That CowDescriptionFarmer John has been
informed of the location of a fugitive cow and wants to catch her immediately.
He starts at a point N (0...
分类:
其他好文 时间:
2014-06-05 19:54:29
阅读次数:
298
题目大意:
一个农主寻找牛。给出农主的位置n和牛的位置k。农主可以通过n-1或者n+1或者n*2的步伐找牛,问至少多少步才能找到自己的牛。解题思路:
简单的BFS。把农主的每一种可能的步伐通过BFS存到栈中,然后看最少多少步到达K坐标。代码: 1 #include 2 #include 3 ...
分类:
其他好文 时间:
2014-05-31 15:27:27
阅读次数:
252