很水的一个BFS,不过还是有坑点的,就是数都是大于1000的,我在千位时取过零,想了很久
不够细心啊!!!
AC代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef __int64 LL;
#define maxn 0x7f...
分类:
其他好文 时间:
2014-07-27 11:28:12
阅读次数:
203
Knight Moves
Description
Background
Mr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?
The P...
分类:
其他好文 时间:
2014-07-26 17:23:32
阅读次数:
590
胜利大逃亡
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 24937 Accepted Submission(s): 9535
Problem Description
Ignatius被魔王抓走了,有一天魔...
分类:
其他好文 时间:
2014-07-26 15:17:10
阅读次数:
305
题目地址:HDU 3468
这道题的关键在于能想到用网络流。然后还要想到用bfs来标记最短路中的点。
首先标记方法是,对每一个集合点跑一次bfs,记录所有点到该点的最短距离。然后对于任意一对起始点来说,只要这个点到起点的最短距离+该点到终点的最短距离==起点到终点的最短距离,就说明这点在某条从起点到终点的最短路上。
然后以集合点建X集,宝物点建Y集构造二分图,将从某集合点出发的最短路中经过宝...
分类:
其他好文 时间:
2014-07-26 15:15:10
阅读次数:
296
Pots
Description
You are given two pots, having the volume of A and B liters respectively. The following operations can be performed:
FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap;DR...
分类:
其他好文 时间:
2014-07-26 15:04:00
阅读次数:
263
SPOJ 206 BITMAP(BFS+剪枝)
ACM
题目地址:SPOJ 206 BITMAP
题意:
给出一个矩阵,有黑白点,计算每个点离最近的白点的距离,p1=(i1,j1) and p2=(i2,j2),距离d(p1,p2)=|i1-i2|+|j1-j2|.
分析:
有剪枝的BFS,如果从黑色的开始进行BFS最近的白色,复杂度是O(n^4),复杂度无法接受。...
分类:
其他好文 时间:
2014-07-26 15:00:41
阅读次数:
254
Flood-Fill. BFS. But there's a trick. If we fill surrounded region directly, extra bookkeeping cost is needed - because we don't know whether that reg...
分类:
其他好文 时间:
2014-07-26 14:58:00
阅读次数:
313
关于围住神经猫的实现的想法,因为水平不高,所以想出来的办法比较基础......
分类:
其他好文 时间:
2014-07-26 02:49:46
阅读次数:
274