![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DFS/BFS
invoKer-
这个作者很懒,什么都没留下…
展开
-
CodeForces - 31D Chocolate【几何】【连通块】
题目链接:https://codeforces.com/contest/31/problem/D#include <iostream>#include <cstdio>#include <cstdlib>#include <cctype>#include <cmath>#include <climits>#include <cstring>#include <vector>#include &l原创 2021-04-29 17:03:06 · 150 阅读 · 0 评论 -
CodeForces - 29D Ant on the Tree【DFS】
题目链接:https://codeforces.com/contest/29/problem/D#include <iostream>#include <cstdio>#include <cstdlib>#include <cctype>#include <cmath>#include <climits>#include <cstring>#include <vector>#include &l原创 2021-02-09 22:44:19 · 147 阅读 · 0 评论 -
CodeForces - 29C Mail Stamps【离散化】【DFS】
题目链接:https://codeforces.com/contest/29/problem/C#include <iostream>#include <cstdio>#include <cstdlib>#include <cctype>#include <cmath>#include <climits>#include <cstring>#include <vector>#include &l原创 2021-02-09 20:49:28 · 155 阅读 · 0 评论 -
CodeForces - 27E Number With The Given Amount Of Divisors【爆搜】
题目链接:https://codeforces.com/contest/27/problem/E约数和定理+爆搜#include <iostream>#include <algorithm>using namespace std;typedef __int128 ll;static const int primes[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};static const ll INFL=100000000原创 2021-01-22 00:45:32 · 140 阅读 · 0 评论 -
CodeForces - 22E Scheme【DFS】
题目链接:https://codeforces.com/contest/22/problem/E#include <iostream>#include <vector>#include <cstring>using namespace std;static const int MAXN=1e5+10;int son[MAXN],d[MAXN];int vis[MAXN];int n;vector<int> h,t;int dfs(int x原创 2020-10-28 19:16:34 · 182 阅读 · 0 评论 -
CodeForces - 19E Fairy【二分图】【DFS】
题目链接:https://codeforces.com/contest/19/problem/E#include <iostream>#include <cstring>using namespace std;static const int MAXN=1e4+10;static const int MAXM=2e4+10;struct Edge{ int u,v; bool trEdge; int odd,even;}edge[MAXN];i原创 2020-10-25 22:29:42 · 153 阅读 · 0 评论 -
CodeForces - 11C How Many Squares?【DFS】
题目链接:https://codeforces.com/contest/11/problem/C来自洛谷题解的做法,先找第一类正方形,再找第二类正方形,dfs找联通块并全部清除,判断1的数量是否构成之前找到的任意一种正方形。#include <iostream>#include <cstring>using namespace std;static const int MAXN=250+10;static const int dx[]={-1,-1,-1,0,0,1,1,原创 2020-09-22 09:52:44 · 433 阅读 · 0 评论 -
[kuangbin]专题二 搜索进阶 DNA sequence HDU - 1560【IDA*】
【题目描述】The twenty-first century is a biology-technology developing century. We know that a gene is made of DNA. The nucleotide bases from which DNA is built are A(adenine), C(cytosine), G(guanine), an...原创 2019-08-08 19:54:23 · 219 阅读 · 0 评论 -
[kuangbin]专题二 搜索进阶 哈密顿绕行世界问题 HDU - 2181【DFS】
【题目描述】一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。【输入】前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m<=20,m>=1.m=0退出.【输出】输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多条路线,按字典序输出,每行1条路线.每行首先输出...原创 2019-08-06 17:25:55 · 97 阅读 · 0 评论 -
[kuangbin]专题二 搜索进阶 Magic Cube ZOJ - 2477【BFS】
【题目描述】This is a very popular game for children. In this game, there’s a cube, which consists of 3 * 3 * 3 small cubes. We can unwrap the cube, it will become like this:w w ww w ww w wr r r g g g ...原创 2019-08-10 13:49:38 · 111 阅读 · 0 评论 -
[kuangbin]专题二 搜索进阶 Nightmare Ⅱ HDU - 3085【BFS】
【题目描述】Last night,little erriyue had a horrible nightmare.He dreamed that he and his girl friend were trapped in a big maze separately.More terribly,there are two ghosts in the maze.They will kill the...原创 2019-08-10 16:40:52 · 132 阅读 · 0 评论 -
[kuangbin]专题二 搜索进阶 Gap HDU - 1067【BFS】【哈希】
【题目描述】Let’s play a card game called Gap.You have 28 cards labeled with two-digit numbers.The first digit (from 1 to 4) represents the suit of the card,and the second digit (from 1 to 7) represents t...原创 2019-08-11 15:27:39 · 289 阅读 · 0 评论 -
[kuangbin]专题二 搜索进阶 A计划 HDU - 2102【BFS】
【题目描述】可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的位置用P表示,时空传输机用#表示...原创 2019-08-11 16:08:16 · 140 阅读 · 0 评论 -
[kuangbin]专题三 Dancing Links Squiggly Sudoku HDU - 4069【DFS】【精确覆盖】
【题目描述】Today we play a squiggly sudoku, The objective is to fill a 9*9 grid with digits so that each column, each row, and each of the nine Connecting-sub-grids that compose the grid contains all of t...原创 2019-08-27 10:57:48 · 168 阅读 · 0 评论 -
CCF-CSP 201809-4 再卖菜【DFS+记忆化】(100分)
试题编号: 201809-4试题名称: 再卖菜时间限制: 1.0s内存限制: 256.0MB问题描述: 问题描述 在一条街上有n个卖菜的商店,按1至n的顺序排成一排,这些商店都卖一种蔬菜。 第一天,每个商店都自己定了一个正整数的价格。店主们希望自己的菜价和其他商店的一致,第二天,每一家商店都会根据他自己和相邻商店的价格调整自己的价格。具体的,每家商店都会将第二天的菜价设置为自己和...原创 2019-09-11 19:10:18 · 392 阅读 · 0 评论 -
CodeForces - 6D Lizards and Basements 2【DFS】
【题目描述】This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.Polycarp lik...原创 2019-10-06 13:50:47 · 167 阅读 · 0 评论 -
[kuangbin]专题二 搜索进阶 Eight II HDU - 3567【反向BFS】【康托展开】【哈希】
【题目描述】Eight-puzzle,which is also called “Nine grids”,comes from an old game.In this game,you are given a 3 by 3 board and 8 tiles.The tiles are numbered from 1 to 8 and each covers a grid.As you see...原创 2019-08-06 15:54:07 · 217 阅读 · 0 评论 -
[kuangbin]专题二 搜索进阶 Escape HDU - 3533【BFS】
【题目描述】The students of the HEU are maneuvering for their military training.The red army and the blue army are at war today.The blue army finds that Little A is the spy of the red army,so Little A has...原创 2019-08-08 16:21:28 · 122 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Find a way HDU - 2612【BFS】
【题目描述】Pass a year learning in Hangzhou,yifenfei arrival hometown Ningbo at finally.Leave Ningbo one year,yifenfei have many people to meet.Especially a good friend Merceki.Yifenfei’s home is at the ...原创 2019-08-04 15:28:35 · 145 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 棋盘问题 POJ - 1321【DFS】
【题目描述】在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。【输入】输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <...原创 2019-08-04 15:30:01 · 2364 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Dungeon Master POJ - 2251【BFS】
【题目描述】You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north...原创 2019-08-01 09:53:51 · 118 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Catch That Cow POJ - 3278【BFS】
【题目描述】Farmer 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 and the cow is at a point K (0 ≤ K ...原创 2019-08-04 15:31:56 · 125 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 非常可乐 HDU - 1495【BFS】
【题目描述】大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N毫升和M毫升可乐的体积为S(S<101)毫升(正好装满一瓶) ,它们三个之间可以相互倒可乐 (都是没有刻度的,且 S==N+M,101>...原创 2019-08-04 14:27:53 · 122 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Oil Deposits HDU - 1241【DFS】
【题目描述】The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that div...原创 2019-08-03 20:46:33 · 147 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 迷宫问题 POJ - 3984【BFS】
【题目描述】定义一个二维数组:int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。【输入】一个5 × 5的二维数组,表示一个...原创 2019-08-03 20:04:19 · 129 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Fire! UVA - 11624【BFS】
【题目描述】Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the owner of the maze neglected to create a fire escape plan. Help Joe escape the maze.Given Joe’s location in...原创 2019-08-03 17:03:04 · 131 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Fire Game FZU - 2150【BFS】
【题目描述】Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this board is consisting of grass or just empty and then the...原创 2019-08-03 15:54:49 · 154 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Pots POJ - 3414【BFS】
【题目描述】You are given two pots, having the volume of A and B liters respectively. The following operations can be performed:1.FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap;2.DROP(i) emp...原创 2019-08-04 15:38:49 · 120 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Fliptile POJ - 3279【DFS】
【题目描述】Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in which they manipulate an M × N grid (1 ≤ M ≤ 15; 1 ≤...原创 2019-08-04 15:41:31 · 217 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Find The Multiple POJ - 1426【BFS】
【题目描述】Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 an...原创 2019-08-01 16:12:45 · 106 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Prime Path POJ - 3126【BFS】
【题目描述】The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a matter...原创 2019-08-04 15:45:14 · 221 阅读 · 0 评论 -
[kuangbin]专题一 简单搜索 Shuffle'm Up POJ - 3087【BFS】
【题目描述】A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C ch...原创 2019-08-04 15:48:39 · 178 阅读 · 0 评论 -
[kuangbin]专题二 搜索进阶 Eight HDU - 1043【反向BFS】【康托展开】【哈希】
【题目描述】The 15-puzzle has been around for over 100 years; even if you don’t know it by that name, you’ve seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and al...原创 2019-08-05 18:49:55 · 380 阅读 · 0 评论 -
UVA - 307 Sticks【DFS】
【题目描述】George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he h...原创 2019-08-03 15:55:14 · 201 阅读 · 0 评论