
搜索(DFS+BFS)
等我学会后缀自动机
侠影之谜
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
CodeForces 936B Sleepy Game (DFS+DP状态记录)
题目链接:https://vjudge.net/contest/303643#problem/B#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long l...原创 2019-06-11 18:10:07 · 206 阅读 · 0 评论 -
HDU 5798 Stabilization (DFS+预处理+剪枝+好题)*
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5798#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2019-02-10 21:19:24 · 214 阅读 · 0 评论 -
HDU 5612 Baby Ming and Matrix games (简单DFS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5612#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2019-02-10 21:04:17 · 195 阅读 · 0 评论 -
Gym 101128A Promotions (拓扑序性质+DFS标记)
题目链接:http://codeforces.com/gym/101128/attachments#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll unsig...原创 2019-02-09 21:08:09 · 204 阅读 · 0 评论 -
Gym 100030F Magic Chains (BFS+HASH)
题目链接:http://codeforces.com/gym/100030/attachments题目大意:给定若干个长度一样的字符串,从第一个字符串出发,每次操作可以改变一个字符,问要变成最后一个字符串最少需要几次变换,并且打印路径。题目分析: 常规的搜索题,一开始很容易想到用MAP结构,但会被超时,如何从若干个字符串中找到一一对应的映射,hash有了用武之地。也...原创 2019-02-16 10:58:45 · 272 阅读 · 0 评论 -
HDU 2260 Difficulty Control(DFS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2260#include<iostream>#include<algorithm>#include<string.h>#include<queue>#include<math.h>using namespace std;lon...原创 2019-02-21 15:12:22 · 160 阅读 · 0 评论 -
HDU 4081 Qin Shi Huang's National Road System (最小生成树+DFS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4081#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll uns...原创 2019-02-08 00:47:56 · 202 阅读 · 0 评论 -
HDU 5876 Sparse Graph (DFS+补图)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5876#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll uns...原创 2019-02-07 21:29:59 · 238 阅读 · 0 评论 -
HDU 5877 Weak Pair (树状数组+DFS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5877#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2019-02-05 22:14:32 · 141 阅读 · 0 评论 -
HDU 5113 Black And White (DFS+剪枝)*
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5113#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2019-02-10 21:26:35 · 285 阅读 · 0 评论 -
Newcoder 21669 牛牛VS牛妹 (博弈+思维)
链接:https://ac.nowcoder.com/acm/problem/21669来源:牛客网题目大意给你一个网格,有些点被#覆盖了不能再走,其他点是空地,现在牛牛和牛妹轮流开始将空地变成#如果当前轮到的人操作之后左上角到右下角不存在通路了,当前操作的人就输了通路只能是从左上角到右下角往右或者往下走的路径牛牛先开始操作,如果双方都是绝顶聪明,输出最后谁赢保证一开始给你的网格...原创 2019-02-26 00:16:49 · 778 阅读 · 0 评论 -
CodeForces 463D Gargari and Permutations (DFS建图+DP)
主要是需要建图,i和j是否可以连边需要比较i的位置是不是每个序列都出现在j的前面,想清楚这点就简单了.#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll l...原创 2019-05-05 12:54:59 · 174 阅读 · 0 评论 -
CodeForces 721C Journey (DFS来模拟DP顺序)
题目链接:http://codeforces.com/problemset/problem/721/CDP+DFS#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#def...原创 2019-04-29 14:43:12 · 227 阅读 · 0 评论 -
Codeforces Round #197 (Div. 2) C. Xenia and Weights(记忆化搜索+map+DP)
题目链接:http://codeforces.com/problemset/problem/339/C开个三维映射的map直接爆搜即可,记忆化下状态一共是1e7这样的级别#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x...原创 2019-04-23 21:11:27 · 119 阅读 · 0 评论 -
CodeForces 893F Subtree Minimum Query (主席树+BFS|DFS)
题目链接:http://codeforces.com/problemset/problem/893/F题目大意给定一棵树和根,每个节点上都有权值,先给定若干个查询(强制在线,要求在题目中)(x,k),问x节点的子树中其距离x不超过k的节点权值的最小值,其中x自己规定距离为0.题目分析思维蛮巧妙的主席树了,,我也是参照了别人的思路才恍然大悟,在数据结构的灵活使用方面...原创 2019-03-27 00:00:28 · 196 阅读 · 0 评论 -
蓝桥杯 历届试题 发现环(DFS)
题目链接:http://lx.lanqiao.cn/problemset.page?code=PREV-&userid=162162#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x...原创 2019-03-23 19:34:05 · 248 阅读 · 0 评论 -
Codeforces Round #541 (Div. 2) E. String Multiplication(繁琐细节+递归)
题目链接:http://codeforces.com/contest/1131/problem/E题目大意给定一个字符串的运算规则,给定若干个字符串,问运算到最后其最长的连续相同串是多长。题目分析首先考虑最后一个串,这题情况稍微有点多,但是理清楚就简单了,首先我们可以维护一个数组is_have[maxn][26]表示前i个串中出现过哪些字符,因为最后一个串是附加...原创 2019-03-15 19:20:42 · 130 阅读 · 0 评论 -
POJ 1240 Pre-Post-erous! (递归+组合数学)
题目链接:http://poj.org/problem?id=1240题目大意给定两个m叉树的先序排列和后序排列,问能有多少种可能的树使得这个序列合法。题目分析递归+组合数学。设定状态:(l1,r1,l2,r2),那么我们不难发现l1下标对应的数在第二个区间中出现的下标为L3,那么这样状态就可以划分了,明显(l1+1,l1+l3-l2,l2,l2,l3-1)是一个...原创 2019-03-03 11:40:52 · 500 阅读 · 0 评论 -
Codeforces Round #541 (Div. 2) D. Gourmet choice(DFS+并查集缩点)
题目链接:http://codeforces.com/contest/1131/problem/D题目大意题目背景没仔细看,大体意思就是有n*m的矩阵,然后(i,j)的符号代表第一类食物的i个和第二类食物的j个的大小关系。问是否存在满足这个矩阵关系的食物,如果存在则构造出来。题目分析思想:用Dp思想,首先是根据偏序关系来建图,用小的自底向上去更新大的,自顶向下我没...原创 2019-03-05 18:28:59 · 145 阅读 · 0 评论 -
HDU 5637 Transform (DFS+记忆化搜索+位运算)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5637#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2019-02-05 22:06:56 · 137 阅读 · 0 评论 -
HDU 2364 Escape (BFS+状态细节)
Escape Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1234 Accepted Submission(s): 524 Problem DescriptionYou find yourself tr...原创 2018-05-08 17:36:05 · 240 阅读 · 0 评论 -
HDU 1728 逃离迷宫(BFS+搜索状态集)
逃离迷宫Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 29 Accepted Submission(s) : 6Font: Times New Roman | Verdana | GeorgiaFont Size: ← →...原创 2018-05-08 17:45:47 · 158 阅读 · 0 评论 -
HDU 4407 Sum (容斥定理+DFS搜索)
SumTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4278 Accepted Submission(s): 1227 Problem DescriptionXXX is puzzled with the quest...原创 2018-08-19 11:58:41 · 211 阅读 · 0 评论 -
HDU 2204 Eddy's爱好 (容斥原理)
Eddy's爱好Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3031 Accepted Submission(s): 1491 Problem DescriptionIgnatius 喜欢收集蝴蝶标本和邮票,但是E...原创 2018-08-18 13:53:27 · 602 阅读 · 0 评论 -
UVA 10817 校长的烦恼(状压DP+记忆化搜索
The headmaster of Spring Field School is considering employing some new teachers for certain subjects. There are a number of teachers applying for the posts. Each teacher is able to teach one or more ...原创 2018-08-12 20:22:03 · 324 阅读 · 0 评论 -
Codeforces 337D Book of Evil (DFS+树的性质 路径唯一性)
Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactl...原创 2018-08-03 11:55:16 · 444 阅读 · 0 评论 -
Codeforces 208C Police Station (BFS+DP计数)
The Berland road network consists of n cities and of m bidirectional roads. The cities are numbered from 1 to n, where the main capital city has number n, and the culture capital — number 1. The road ...原创 2018-08-02 23:10:19 · 289 阅读 · 0 评论 -
Atcoder contest 078 D - Fennec VS. Snuke (BFS+思维)。。。DFS也可以
D - Fennec VS. SnukeTime limit : 2sec / Memory limit : 256MBScore : 400 pointsProblem StatementFennec and Snuke are playing a board game.On the board, there are N cells numbered 1 through N,...原创 2018-08-01 16:51:23 · 274 阅读 · 0 评论 -
Codeforces 618 D Hamiltonian Spanning Tree (思维+DFS找路径)*
A group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are roads in total. It takes exactly y seconds to traverse any single road....原创 2018-07-26 16:19:23 · 334 阅读 · 0 评论 -
ZOJ 2103 Marco Popo the Traveler(搜索水题)
Marco Popo the TravelerTime Limit: 2 Seconds Memory Limit: 65536 KBMarco Popo, the famous traveler, is traveling around the country of ACM. There are colored high-ways between cities (of co...原创 2018-07-25 11:51:41 · 237 阅读 · 0 评论 -
ACM-ICPC 2018 南京赛区网络预赛 AC Challenge (状态压缩+暴力)
Dlsj is competing in a contest with n(0<n≤20)n (0 < n \le 20)n(0<n≤20) problems. And he knows the answer of all of these problems.However, he can submit iii-th problem if and only if he has...原创 2018-09-01 23:04:22 · 397 阅读 · 0 评论 -
HDU 2586 How far away ? (LCA_Tarjan)
How far away ?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 23711 Accepted Submission(s): 9434 Problem DescriptionThere are n house...原创 2018-08-30 14:04:28 · 194 阅读 · 0 评论 -
HDU 1180 诡异的楼梯(BFS+状态选择)
诡异的楼梯Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)Total Submission(s) : 19 Accepted Submission(s) : 4Font: Times New Roman | Verdana | GeorgiaFont Size: ←...原创 2018-05-08 17:54:32 · 130 阅读 · 0 评论 -
HDU 1226 超级密码(数位BFS+同余剪枝+边界值)
超级密码Time Limit : 20000/10000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 10 Accepted Submission(s) : 3Font: Times New Roman | Verdana | GeorgiaFont Size: ←...原创 2018-05-08 17:56:30 · 163 阅读 · 1 评论 -
HDU 5094 Maze(BFS+状态压缩)
MazeTime Limit : 2000/1000ms (Java/Other) Memory Limit : 100000/100000K (Java/Other)Total Submission(s) : 9 Accepted Submission(s) : 3Font: Times New Roman | Verdana | GeorgiaFont Size: ← ...原创 2018-05-09 07:21:44 · 201 阅读 · 0 评论 -
CodeForces 598D Igor In the Museum (DFS+预处理)
题目链接:http://codeforces.com/problemset/problem/598/D#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2019-01-24 15:11:57 · 274 阅读 · 0 评论 -
Gym 101142C CodeCoder vs TopForces (搜索+图论)
题目链接:http://codeforces.com/gym/101142/attachments#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long ...原创 2018-12-09 00:21:39 · 287 阅读 · 0 评论 -
HDU 4678 Mine (bfs+博弈SG)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4678#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll lon...原创 2018-10-29 15:49:04 · 162 阅读 · 0 评论 -
Codeforces Round #516 (Div. 2) D. Labyrinth (简单BFS)
题目链接:http://codeforces.com/contest/1064/problem/D#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define read(x,y...原创 2018-10-14 21:49:45 · 307 阅读 · 0 评论 -
UVA 10798 Be wary of Roses (BFS+几何状态对称)*
题目链接:https://cn.vjudge.net/problem/UVA-10798#include<bits/stdc++.h>#pragma comment(linker,"/STACK:1024000000,1024000000")using namespace std;#define debug puts("YES");#define rep(x,y,z) ...原创 2018-09-08 06:28:51 · 265 阅读 · 0 评论