
ACM--搜索
文章平均质量分 78
努力过
喜欢coding
展开
-
NYoj 1237-最大岛屿 【输入带坑的DFS】
题目描述: 神秘的海洋,惊险的探险之路,打捞海底宝藏,激烈的海战,海盗劫富等等。加勒比海盗,你知道吧?杰克船长驾驶着自己的的战船黑珍珠1号要征服各个海岛的海盜,最后成为海盗王。 ...原创 2018-05-10 23:35:59 · 390 阅读 · 0 评论 -
uva 11882 C - Biggest Number 【最优性剪枝】【深搜】
题意:给定一个n*m的矩阵,'#'表示不能通过,每个方格只能走过一次且下一步只能走上下左右四个方向,问,能够组成最大连续的数字为多大?思路:最优性剪枝即当前所搜索到的结点的后续最优情况也不比当前最优情况好,就停止对当前结点的搜索,回溯到其父亲结点,搜索其它情况。这里用到了两个剪枝,一个是当前已搜索到的数字长度+后续能搜索到的数字长度小于最优值时,直接剪枝;另一个是长度相等时,判断字典序大小,前者较...原创 2018-05-08 15:38:32 · 486 阅读 · 0 评论 -
UVA 3902 A - Network 【dfs+建树+贪心】
题意:给定n,s,k,分别表示树有n个结点,服务器位于s结点,只要客服端(叶节点为客户端)不超过服务器k距离,则都可以覆盖,问最少需要布置多少个服务器能够覆盖全部客户端思路:1:将无根树转为有根树,并将每层的叶节点关系保存 2:从第n-1个叶结点开始查找它的k级祖先,放置服务器在k级祖先处,并将距离k级祖先小于k距离的所有叶节点覆盖(方便下一次查找跳过)结:第一次用c++的vec...原创 2018-04-28 20:41:28 · 188 阅读 · 0 评论 -
poj 3009 Curling 2.0 【dfs】
On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is mark原创 2018-01-30 13:53:00 · 190 阅读 · 0 评论 -
poj3083 Children of the Candy Corn【bfs+dfs】【刷题计划】
Children of the Candy CornTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 14452 Accepted: 6233DescriptionThe cornfield maze is a popular H原创 2017-12-30 17:50:05 · 829 阅读 · 0 评论 -
poj 2488 A Knight's Journey 【dfs】【字典序】【刷题计划】
A Knight's JourneyTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 47516 Accepted: 16161DescriptionBackground The knight is getting bored原创 2017-11-27 12:53:06 · 222 阅读 · 0 评论 -
hdu 2364 Escape【模拟优先队列】【bfs】
EscapeTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1182 Accepted Submission(s): 500Problem DescriptionYou find yourself trappe原创 2017-11-12 12:01:45 · 225 阅读 · 0 评论 -
poj 2965 The Pilots Brothers' refrigerator 【dfs+枚举】【双十一大礼包】【刷题计划】
The Pilots Brothers' refrigeratorTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 27522 Accepted: 10625 Special JudgeDescriptionThe原创 2017-11-11 16:07:10 · 278 阅读 · 0 评论 -
poj1753Flip Game【刷题计划】
Flip GameTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 47766 Accepted: 20383DescriptionFlip game is played on a rectangular 4x4 field wi原创 2017-11-04 19:43:42 · 509 阅读 · 0 评论 -
hdu 1242 Rescue【bfs+优先队列(c语言模拟)】
#include#include#includeusing namespace std;#define N 210#define inf 0x3f3f3f3fchar map[N][N];int book[N][N],m,n,si,sj,ans;struct node{ int x,y,time;}q[N*N];int cmp(struct node a,stru原创 2017-09-22 09:54:13 · 425 阅读 · 0 评论 -
hdu2571命运【bfs】
Problem Description穿过幽谷意味着离大魔王lemon已经无限接近了!可谁能想到,yifenfei在斩杀了一些虾兵蟹将后,却再次面临命运大迷宫的考验,这是魔王lemon设下的又一个机关。要知道,不论何人,若在迷宫中被困1小时以上,则必死无疑!可怜的yifenfei为了去救MM,义无返顾地跳进了迷宫。让我们一起帮帮执着的他吧!命运大迷宫可以看成是一个两维的方格阵列原创 2017-09-19 08:29:43 · 402 阅读 · 0 评论 -
A - Prime Ring Problem uva524素数环【dfs】
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=465题意:输入整数n,把1...n的组成环,使得相邻两个整数之和均为素数。输出排列的方案环。思路:先生成一个素数数组,便于之后进行判断。我用的回溯法,有人说用dp哎原创 2017-09-11 22:57:39 · 233 阅读 · 0 评论 -
hdu 2553 N皇后问题【dfs】
N皇后问题Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 25886 Accepted Submission(s): 11504Problem Description在N*N的方格棋盘放置了N个皇后,使得它原创 2017-09-11 17:16:38 · 310 阅读 · 0 评论 -
poj 1753【枚举+dfs(位向量法)】
Flip GameTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 46519 Accepted: 19915DescriptionFlip game is played on a rectangular 4x4 field wi原创 2017-08-30 11:00:03 · 341 阅读 · 0 评论 -
河南省第七届大学生程序设计竞赛 问题 A: 物资调度【简单dfs】
题目描述某地区发生了地震,灾区已经非常困难,灾民急需一些帐篷、衣物、食品和血浆等物资。可通往灾区的道路到处都是塌方,70%以上的路面损坏,桥梁全部被毁。国家立即启动应急预案,展开史上最大强度的非作战式的空运行动,准备向灾区投放急需物资。 一方有难,八方支援。现在已知有N个地方分别有A1,A2,….,An个物资可供调配。目前灾区需要物资数量为M。 现在,请你帮忙算一算,总共有原创 2017-08-23 08:25:26 · 354 阅读 · 0 评论 -
【练习赛补题】问题 D: 最短路径问题 hdu3790【dfs】
题目描述 给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。输入输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后一行是两个数 s,t;起点s,终点t。n和m为0时输入结束。(1原创 2017-08-21 16:20:11 · 266 阅读 · 0 评论 -
【练习赛补题】poj 3026 Borg Maze 【bfs+最小生成树】【坑~】
DescriptionThe Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg原创 2017-08-19 10:30:30 · 285 阅读 · 0 评论 -
【练习赛2补题】zoj 2734 Exchange Cards 【DFS】
As a basketball fan, Mike is also fond of collecting basketball player cards. But as a student, he can not always get the money to buy new cards, so sometimes he will exchange with his friends for car原创 2017-08-18 17:25:57 · 282 阅读 · 0 评论 -
【搜索入门专题1】 hdu1242 J - Rescue c++ stl容器之优先队列+BFS
RescueProblem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M Angel's friends want to save Angel. Their task is: a原创 2017-07-31 07:40:12 · 507 阅读 · 0 评论 -
【搜索入门专题1】E - Farm Irrigation 【BFS】ZOJ 2412
Farm IrrigationBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square原创 2017-07-30 17:43:48 · 255 阅读 · 0 评论 -
【搜索入门专题1】hdu1253 【BFS】 F - 胜利大逃亡
胜利大逃亡Problem DescriptionIgnatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会.魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C的矩阵,刚开始Ignatius被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-1)的位置,现在知道魔王将在T分钟后回到城堡,Ignatius每分钟原创 2017-07-30 13:31:41 · 306 阅读 · 0 评论 -
【搜索入门专题1】hdu2717 H - Catch That Cow 【BFS】
Catch That CowProblem DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line a原创 2017-07-30 10:16:33 · 220 阅读 · 0 评论 -
【搜索入门专题1】hdu1548 G - A strange lift 【BFS】
A strange liftProblem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two bu原创 2017-07-30 09:34:35 · 268 阅读 · 0 评论 -
【搜索入门专题1】I - Knight Moves hdu1372 c++queue的应用 【BFS】
Knight MovesProblem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of原创 2017-07-29 17:35:39 · 267 阅读 · 0 评论 -
【搜索入门专题练习1】hdu1241+hdu1312 C+D【DFS】
Oil DepositsProblem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a t原创 2017-07-29 14:54:41 · 224 阅读 · 0 评论 -
【搜索入门专题练习1】hdu1010 dfs奇偶剪枝 A题
A - Tempter of the Bone原创 2017-07-29 12:22:43 · 353 阅读 · 0 评论 -
练习赛2(补题) 问题 C: 迷宫问题 【BFS模板题】
问题 C: 迷宫问题题目描述小明置身于一个迷宫,请你帮小明找出从起点到终点的最短路程。小明只能向上下左右四个方向移动。输入输入包含多组测试数据。输入的第一行是一个整数T,表示有T组测试数据。每组输入的第一行是两个整数N和M(1接下来N行,每行输入M个字符,每个字符表示迷宫中的一个小方格。字符的含义如下:‘S’:起点‘E’:终点‘-’:空地,可以通原创 2017-07-23 16:49:56 · 3030 阅读 · 0 评论 -
TJU 1398 Square DFS
**Given a set of sticks of various lengths, is it possible to join them end-to-end to form a square? The first line of input contains N, the number of test cases. Each test case begins with an integer原创 2017-05-19 23:14:12 · 318 阅读 · 0 评论 -
hdu1426数独游戏Sudoku Killer DFS
**Problem Description 自从2006年3月10日至11日的首届数独世界锦标赛以后,数独这项游戏越来越受到人们的喜爱和重视。 据说,在2008北京奥运会上,会将数独列为一个单独的项目进行比赛,冠军将有可能获得的一份巨大的奖品———HDU免费七日游外加lcy亲笔签名以及同hdu acm team合影留念的机会。 所以全球人民前仆后继,为了奖品日夜训练茶饭不思。当然也包括初学者l原创 2017-05-19 12:58:39 · 423 阅读 · 0 评论 -
DFS水题
题目描述 小明站在一个矩形房间里,这个房间的地面铺满了地砖,每块地砖的颜色或是红色或是黑色。小明一开始站在一块黑色地砖上,并且小明从一块地砖可以向上下左右四个方向移动到其他的地砖上,但是他不能移动到红色地砖上,只能移动到黑色地砖上。 请你编程计算小明可以走到的黑色地砖最多有多少块。 输入 输入包含多组测试数据。 每组输入首先是两个正整数W和H,分别表示地砖的列行数。(1<=W,H<=20)原创 2017-04-24 19:02:24 · 1053 阅读 · 0 评论 -
hdu1241dfs水题
“ `Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 30121 Accepted Submission(s): 17416Problem Description The GeoSurvComp原创 2017-04-21 06:12:58 · 594 阅读 · 1 评论