![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DFS
文章平均质量分 79
Rocky0429
我愿能朝着太阳生长,做一个温暖的人。
展开
-
走迷宫(Dfs)
走迷宫 Time Limit: 1000MS Memory limit: 65536K 题目描述一个由n * m 个格子组成的迷宫,起点是(1, 1), 终点是(n, m),每次可以向上下左右四个方向任意走一步,并且有些格子是不能走动,求从起点到终点经过每个格子至多一次的走法数。输入 第一行一个整数T 表示有T 组测试数据。(T <= 110)原创 2014-11-13 20:37:42 · 1398 阅读 · 0 评论 -
HDU 5339-Untitled(dfs)
题目地址:HDU 5339 题意:给出n个数和一个数a,问a对其中的一些数取余(可以为n个数),是否a能等于0 思路:遍历枚举,每次找<=a的数,然后取余,一直到最后看是否为0#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstr原创 2015-08-03 08:38:05 · 1336 阅读 · 3 评论 -
HDU 5319(2015多校3)-Painter(dfs)
题目地址:HDU 5319 题意:给一个图n*m,原来全是点(’.’)。 现在要把图染成已给出的样子。 要求当是’\’的情况只用红色,是’/’的情况只用蓝色,当一个格子同时被红色和蓝色染得时候变成绿色。(每个格子只画一次)。 思路:这题只要模拟一下刷的过程就行了,如果出现了R,就刷R刷到底,出现B就刷B,出现G就左右各刷一次。#include <stdio.h>#include <math.h原创 2015-07-29 16:23:59 · 1446 阅读 · 1 评论 -
HDU 5323(2015多校3)-Solve this interesting problem(dfs+剪枝)
题目地址:HDU 5323 题意:给一个l,r,表示区间[l,r],问是否存在区间为[0,n]的线段树的节点区间为[l,r],如果有求最小的n,如果没有输出-1。 思路:因为L/(R-L+1)<=2015,按照线段树的性质每次分区间序号扩大两倍,所以可以得出差不多有22层,所以用爆搜就可以,由上把[l,r]区间不断扩张,直到满足l==0为止。顺便剪剪枝。#include <stdio.h>#i原创 2015-07-30 10:04:09 · 716 阅读 · 0 评论 -
HDU 5326(2015多校3)-Work(dfs)
题目地址:HDU 5326 题意:给一张有向图n个点,n - 1(。。。。输入n-1)条边。 A指向B代表A管理B,然后可以间接管理,比如A管理B,B管理C,则A管理C。 现在问管理k个人的人有多少个。#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#i原创 2015-07-29 16:29:37 · 1307 阅读 · 0 评论 -
UVA 539-The Settlers of Catan(dfs)
The Settlers of CatanTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionWithin Settlers of Catan, the 1995 German原创 2015-03-14 16:44:45 · 1197 阅读 · 0 评论 -
UVA 657-The die is cast(dfs*2)
The die is castTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionInterGames is a high-tech startup company that specializes in develop原创 2015-02-13 20:23:03 · 1283 阅读 · 0 评论 -
UVA 784-Maze Exploration(dfs)
Maze Exploration A maze of rectangular rooms is represented on a two dimensional grid as illustrated in figure 1a. Each point of the grid is represented by a character. The points of room walls are原创 2015-02-14 00:11:07 · 1302 阅读 · 0 评论 -
POJ 2488-A Knight's Journey(dfs)
A Knight's JourneyTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 32823 Accepted: 11178DescriptionBackground The knight is getting bored of seeing原创 2015-02-18 11:42:52 · 1300 阅读 · 0 评论 -
POJ 1321-棋盘问题(dfs)
棋盘问题Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 24577 Accepted: 12150Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,原创 2015-02-18 19:39:37 · 8841 阅读 · 7 评论 -
POJ 2531-Network Saboteur(dfs+剪枝)
Network SaboteurTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 9544 Accepted: 4542DescriptionA university network is composed of N computers. Syste原创 2015-02-20 21:09:15 · 3710 阅读 · 2 评论 -
POJ 3009-Curling 2.0(dfs+剪枝)
Curling 2.0Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 12846 Accepted: 5404DescriptionOn Planet MM-21, after their Olympic games this year, curl原创 2015-02-18 19:02:14 · 1220 阅读 · 0 评论 -
POJ 3083-Children of the Candy Corn(dfs+bfs)
Children of the Candy CornTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 10380 Accepted: 4485DescriptionThe cornfield maze is a popular Halloween t原创 2015-02-17 12:57:27 · 1395 阅读 · 0 评论 -
UVA 572- Oil Deposits(简单dfs)
Oil DepositsTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionThe GeoSurvComp geologic survey company is responsible for detecting u原创 2015-02-13 17:37:11 · 1568 阅读 · 0 评论 -
图的深度遍历(DFS)
图的深度遍历Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^题目描述请定一个无向图,顶点编号从0到n-1,用深度优先搜索(DFS),遍历并输出。遍历时,先遍历节点编号小的。输入输入第一行为整数n(0 输出输出有n行,对应n组输出,每行为用空格隔开的k个整数,对应一组数据,表示DFS的遍历结果。原创 2014-09-14 23:45:56 · 1603 阅读 · 0 评论 -
SDUT 3361-数据结构实验之图论四:迷宫探索(dfs)
题目地址:SDUT 3361#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#原创 2015-11-26 16:08:42 · 1472 阅读 · 0 评论