普通的三维广搜,需要注意的是输入:列,行,层
#include
#include
#include
#include
#include
#define M 11
using namespace std;
int dir[6][3]={{0,1,0},{0,-1,0},{1,0,0},{-1,0,0},{0,0,1},{0,0,-1}};//6个方向
int vis[M][M][M];
char...
分类:
其他好文 时间:
2014-07-30 17:36:24
阅读次数:
266
BFS的思想:从一个图的某一个顶点V0出发,首先访问和V0相邻的且未被访问过的顶点V1、V2、……Vn,然后依次访问与V1、V2……Vn相邻且未被访问的顶点。如此继续,找到所要找的顶点或者遍历完整个图。由此可以看出,用BFS进行搜索所搜索的顶点都是按深度进行扩展的,先找到到V0距离为1的所有顶点,....
分类:
其他好文 时间:
2014-07-30 17:22:44
阅读次数:
239
诡异的楼梯
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 8717 Accepted Submission(s): 2148
Problem Description
Hogwarts正式开学以后,Harr...
分类:
其他好文 时间:
2014-07-30 14:56:53
阅读次数:
287
我们知道,增广路EK算法的时间负责度是O(n*m^2),找最短增广路的时间复杂度是O(m*n),所以时间复杂度主要是在找增广路上。
这里介绍另一种Dinci算法,用BFS构造层次图,然后用DFS增广。
模板
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#d...
分类:
其他好文 时间:
2014-07-30 14:49:03
阅读次数:
364
Problem Description
Given a positive integer n, your task is to find a positive integer m, which is a multiple of n, and that m contains the least number of different digits when represented in decim...
分类:
其他好文 时间:
2014-07-30 14:46:03
阅读次数:
230
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which...
分类:
其他好文 时间:
2014-07-30 11:30:33
阅读次数:
247
DFS(Depth First Search) 深度优先搜索BFS (Breadth First Search)宽度优先搜索在算法中常用这两种方法。1) DFS考虑用“递归”实现和用 “栈”实现两种方法,因为对于大型问题搜索深度比较深,如果用递归实现的话,栈空间占用比较多,递归调用需要的额外时间也比...
分类:
其他好文 时间:
2014-07-30 09:54:03
阅读次数:
234
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded ...
分类:
其他好文 时间:
2014-07-30 09:50:33
阅读次数:
296
HDU 1026 Ignatius and the Princess I (基本算法-BFS)
题目大意:
给定1张图,走到“.”需要1步,走到数字除了需要1步,还要停留数字上那么多步,“#”不能走,问你从左上角到右下至少走多少步,并输出路径
解题思路:
简单的BFS,再加上记录前1步可以从终点往前来获得路径。...
分类:
其他好文 时间:
2014-07-29 22:01:23
阅读次数:
368