
dfs bfs 搜索
研发之道
一个坚持把架构做到极致的技术人,热衷于互联网技术。混迹互联网十几年,热衷于高性能、高并发、分布式技术领域的研究。
展开
-
浙大 ZOJ 1002 Fire Net
Fire NetTime Limit: 2 Seconds Memory Limit: 65536 KB Suppose that we have a square city with straight streets. A map of a cit原创 2015-05-02 23:51:23 · 887 阅读 · 0 评论 -
spoj Goblin Wars(简单bfs)
J - Goblin WarsTime Limit:432MS Memory Limit:1572864KB 64bit IO Format:%lld & %lluSubmitStatusPracticeSPOJ AMR11JDescription The wizards and witches of Hogwarts School of Witchcraf原创 2015-07-30 10:15:30 · 897 阅读 · 0 评论 -
杭电 HDU ACM 1175 连连看(麻烦的bfs)
连连看Time Limit:10000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmitStatusPracticeHDU 1175Description“连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过原创 2015-07-31 10:14:44 · 1629 阅读 · 0 评论 -
杭电 HDU ACM 2612 Find a way (简单两路广搜)
欢迎参加——每周六晚的BestCoder(有米!)Find a wayTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6362 Accepted Submission(s): 2116Problem Des原创 2015-07-31 09:47:27 · 2864 阅读 · 0 评论 -
杭电 HDU 1312 Red and Black(超级简单dfs)
Red and BlackTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12907 Accepted Submission(s): 7983Problem DescriptionThere is a rect原创 2015-07-31 10:22:43 · 1525 阅读 · 0 评论 -
杭电 HDU ACM 1548 A strange lift(简单广搜)
C - A strange liftTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmitStatusPracticeHDU 1548DescriptionThere is a strange lift.The lift can stop can at ev原创 2015-07-31 10:00:09 · 1885 阅读 · 0 评论 -
杭电 HDU ACM 1015 Safecracker (dfs 枚举排列)
SafecrackerTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10614 Accepted Submission(s): 5431Problem Description=== Op tech brief原创 2015-08-27 19:48:38 · 1594 阅读 · 0 评论 -
哈理工 OJ Fire Maze(2次bfs)
题意:‘#’是墙 ,F是火,S起始点,人一秒走一格,火也是1秒扩散一格,问在给定的时间T内是否人可以逃出去。思路:很明显两次bfs 第一次先求出火扩散到每个格子时的 时刻。第二次在对人进行bfs的时候就多了个条件,那就是人不能走大于等于着火时刻的点。 开始竟然以为是1个火点!!!!!悲剧啊 。。。知道这个后就没啥了。。。。AC:/*=====================原创 2015-09-07 21:07:18 · 707 阅读 · 0 评论 -
哈理工 oj 1948 我又回来了(bfs 或着 最短路)
至于题意:已经说的很清楚了:我又回来了Time Limit: 1000 MSMemory Limit: 32768 KTotal Submit: 46(20 users)Total Accepted: 21(16 users)Rating:Special Judge: NoD原创 2015-09-07 21:14:45 · 1617 阅读 · 0 评论 -
zoj 1003 Crashing Balloon(两次dfs)
Crashing BalloonTime Limit: 2 Seconds Memory Limit: 65536 KB On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV. The rule is very simple. On th原创 2015-09-02 22:17:11 · 1550 阅读 · 1 评论 -
UVa 1599 Ideal Path
给一个n个顶点m条边 的无向图。每条边上都涂有一种颜色。求从结点1 到 结点n 的一条路径, 使得经过的边数尽量少,在此前提下, 经过的边的颜色的序列的字典序最小。一对节点间可能有多条边,一条边可能连接两个相同结点。输入保证结点1 可以到达结点n。这里用数组模拟链表来存储边。我们首先一次逆向bfs()构造分层网络。然后正向bfs每一步沿着分层步数递减的方向走,每次走的时候标记上在哪原创 2015-11-18 19:52:34 · 798 阅读 · 0 评论 -
Uva 439 Knight Moves
Knight MovesTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmitStatus DescriptionA friend of you is doing research on the Traveling Knight原创 2015-11-18 19:55:08 · 509 阅读 · 0 评论 -
哈理工练习赛 杭电 HDU Prime Path 1973 poj 3126 Prime Path
C - Prime PathTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmitStatusPracticePOJ 3126DescriptionThe ministers of the cabinet were quite upset by the mess原创 2015-11-29 21:39:54 · 871 阅读 · 0 评论 -
hihoCoder - 1519 : 逃离迷宫II(宽搜)
1519 : 逃离迷宫II时间限制:10000ms 单点时限:1000ms 内存限制:256MB描述小Hi被坏女巫抓进里一间有N x M个格子组成的矩阵迷宫。有些格子是小Hi可以经过的,我们用’.’表示;有些格子上有障碍物小Hi不能经过,我们用’#’表示。小Hi的起始位置用’S’表示,他需要到达用’T’表示的格子才能逃离迷宫。麻烦的是小Hi被坏女巫施了魔法,他只能选择上下左右某一个方向,沿着这个原创 2017-05-11 10:14:45 · 1213 阅读 · 0 评论 -
UVa 572 - Oil Deposits (简单dfs)
DescriptionGeoSurvComp地质调查公司负责探测地下石油储藏。 GeoSurvComp现在在一块矩形区域探测石油,并把这个大区域分成了很多小块。他们通过专业设备,来分析每个小块中是否蕴藏石油。如果这些蕴藏石油的小方格相邻,那么他们被认为是同一油藏的一部分。在这块矩形区域,可能有很多油藏。你的任务是确定有多少不同的油藏。Input输入可能有多个矩形区域原创 2015-07-30 10:09:13 · 981 阅读 · 0 评论 -
杭电 HDU 2717 Catch That Cow
Catch That CowTime Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8999 Accepted Submission(s): 2837Problem DescriptionFarmer John has原创 2015-07-29 00:25:08 · 1427 阅读 · 0 评论 -
ZOJ 1028 Flip and Shift
Flip and ShiftTime Limit: 2 Seconds Memory Limit: 65536 KB This puzzle consists of a random sequence of m black disks and n原创 2015-05-03 08:49:43 · 973 阅读 · 0 评论 -
杭电 HDU ACM 1046 Tempter of the Bone
Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 83458 Accepted Submission(s): 22740Problem DescriptionThe dogg原创 2015-05-01 23:15:06 · 737 阅读 · 0 评论 -
HDU ACM 1072 Nightmare
NightmareTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8125 Accepted Submission(s): 3896Problem DescriptionIgnatius had a night原创 2015-05-12 00:37:00 · 1287 阅读 · 0 评论 -
HDU ACM 4255 A Famous Grid
A Famous GridTime Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1562 Accepted Submission(s): 603Problem DescriptionMr. B has recent原创 2015-05-12 00:13:39 · 1300 阅读 · 0 评论 -
北大 oj 1088 滑雪
问题描述:Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21原创 2015-05-04 23:28:45 · 2309 阅读 · 2 评论 -
Poj 1979 Red and Black
Online JudgeProblem SetAuthorsOnline ContestsUserWeb BoardHome PageF.A.QsStatistical ChartsProblemsSubmit ProblemOnline StatusProb.ID:RegisterUpdate your info原创 2015-05-05 12:37:20 · 791 阅读 · 0 评论 -
杭电 HDU ACM 2199 Can you solve this equation?
Can you solve this equation?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11180 Accepted Submission(s): 5151Problem Description原创 2015-05-01 10:01:50 · 1027 阅读 · 0 评论 -
Nyoj 20 吝啬的国度(dfs)
吝啬的国度时间限制:1000 ms | 内存限制:65535 KB难度:3描述 在一个吝啬的国度里有N个城市,这N个城市间只有N-1条路把这个N个城市连接起来。现在,Tom在第S号城市,他有张该国地图,他想知道如果自己要去参观第T号城市,必须经过的前一个城市是几号城市(假设你不走重复的路)。输入第一行输入一个整数M表示测试数据共有M(1每组测原创 2015-05-07 15:17:53 · 820 阅读 · 0 评论 -
杭电 HDU ACM 1728 逃离迷宫
逃离迷宫Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18241 Accepted Submission(s): 4409Problem Description 给定一个m × n (m行, n列)的迷宫,原创 2015-05-08 01:15:30 · 2336 阅读 · 0 评论 -
UVA 1103 Ancient Messages (DFS)
起初学习dfs的时候 看不懂这个题目 回过头来今天看的时候思路相对比较清晰了。但还是想不到怎么处理 查询有多少个空白洞。并且一个图中还有好多个象形字符。网上思路是 在周围扩展一圈0,使得文字之外的所有0 都连通,一次dfs标记所有文字之外的0为-1。然后遍历图,发现1就沿着有1 的路径dfs2,在这个过程中,如果发现0,那么必然是文字内部的空洞,此时把空洞dfs 置为-1,标记以后不再走。那么发原创 2015-06-20 23:40:55 · 1400 阅读 · 1 评论 -
Uva Abbott’s Revenge 816
还是以前看不懂的一个题目,现在回头看起来 水死了 ,但是好像让我写也是写不出来的。对照着网上的实现。也算全部理解了,代码都经过我详细注释。里面感觉有很多 搜索的惯用思维方法,应该学会如何把这种常见问题抽象成代码方案。比如如何判断行走的方法。学会怎么刻画最短路径搜索树!#include#include#include#include#include#include#include#原创 2015-06-24 13:08:50 · 1744 阅读 · 0 评论 -
poj1041 John's trip (无向图求欧拉回路方案)
John's tripTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5950 Accepted: 1946 Special JudgeDescriptionLittle Johnny has got a new car. He dec原创 2015-06-25 12:40:35 · 811 阅读 · 0 评论 -
杭电 HDU ACM 1016 Prime Ring Problem
Prime Ring ProblemTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31900 Accepted Submission(s): 14108Problem DescriptionA ring is原创 2015-05-04 00:01:53 · 1197 阅读 · 0 评论 -
Uva 572 Oil Deposits
Oil DepositsTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Submit Status DescriptionThe GeoSurvComp geologic survey company is responsible for det...原创 2015-05-08 22:09:34 · 631 阅读 · 0 评论