ACM广度优先搜索
桑榆207
在最终的结果到来之前,任何肯定会赢之类的话都是虚无缥缈的。
展开
-
穿越雷区 BFS
问题 1825: [蓝桥杯][2015年第六届真题]穿越雷区时间限制: 1Sec 内存限制: 128MB 提交: 339 解决: 231题目描述X星的坦克战车很奇怪,它必须交替地穿越正能量辐射区和负能量辐射区才能保持正常运转,否则将报废。某坦克需要从A区到B区去(A,B区本身是安全区,没有正能量或负能量特征),怎样走才能路径最短?已知的地图是一个方阵,上面用字母标出了A,B区,其它...原创 2020-02-12 11:55:26 · 232 阅读 · 0 评论 -
学霸的迷宫 BFS+贪心
问题 1923: [蓝桥杯][算法提高VIP]学霸的迷宫时间限制: 1Sec 内存限制: 128MB 提交: 558 解决: 111题目描述学霸抢走了大家的作业,班长为了帮同学们找回作业,决定去找学霸决斗。但学霸为了不要别人打扰,住在一个城堡里,城堡外面是一个二维的格子迷宫,要进城堡必须得先通过迷宫。因为班长还有妹子要陪,磨刀不误砍柴功,他为了节约时间,从线人那里搞到了迷宫的地图,准备...原创 2020-02-10 12:19:08 · 207 阅读 · 0 评论 -
Dungeon Master POJ - 2251 三维BFS
题意:给出起点和终点、不能走的点,求出是否可以从起点到终点,按条件输出。思路:三维BFS,和二维差不多,记录一下写法。代码:#include<iostream>#include<algorithm>#define rep(i,a,b) for(int i=a;i<=b;i++)#define ll long long#include<...原创 2020-02-04 20:50:50 · 87 阅读 · 0 评论 -
BFS+思维
标题:穿越雷区X星的坦克战车很奇怪,它必须交替地穿越正能量辐射区和负能量辐射区才能保持正常运转,否则将报废。某坦克需要从A区到B区去(A,B区本身是安全区,没有正能量或负能量特征),怎样走才能路径最短?已知的地图是一个方阵,上面用字母标出了A,B区,其它区都标了正号或负号分别表示正负能量辐射区。例如:A + - + -- + - - +- + + + -+ - + - +B...原创 2019-05-15 17:20:32 · 124 阅读 · 0 评论 -
ZOJ4020--Traffic Light--BFS+思维
DreamGrid City is a city withintersections arranged into a grid ofrows andcolumns. The intersection on the-th row and the-th column can be described as, and two intersectionsandare connec...原创 2019-05-15 20:07:43 · 121 阅读 · 0 评论 -
BFS记录路径
19蓝桥杯走迷宫#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>#include<string>#include<vector>...原创 2019-05-15 20:11:13 · 901 阅读 · 0 评论 -
CF图论一--Statues--预处理+搜索
C. Statuestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this task Anna and Maria play a game with a very unpleasant rival. ...原创 2019-07-30 08:11:31 · 247 阅读 · 0 评论 -
CF--King's Path--BFS+STL综合
C. King's Pathtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe black king is standing on a chess field consisting of109rows...原创 2019-08-03 10:36:01 · 175 阅读 · 0 评论 -
51NOD--2603 逃出城堡--思维+BFS
2603 逃出城堡1.0 秒 131,072.0 KB 20 分 3级题小Biu被困在一个城堡中,城堡可以看成一个大小为n*n的二维平面上的网格图,每一个格子要么为平地,要么为墙壁,要么为毒区,而且作为毒区的格子,每一秒会向他周围的上下左右四个格子扩散毒气(毒气不能穿过墙壁)。现在小Biu身负重任,最开始小Biu在某一个平地上,他每一秒可以向他上下左右四个格子中的作为...原创 2019-08-05 15:38:37 · 541 阅读 · 0 评论 -
大连网络赛--Sparse Graph--BFS求补图中无权最短路径
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 3083Accepted Submission(s): 1035 Problem Description I...原创 2019-08-17 08:22:16 · 111 阅读 · 0 评论 -
HDU--Dice--隐式图搜索
Dice Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2488Accepted Submission(s): 1235 Problem Description There are 2 ...原创 2019-08-29 11:32:49 · 90 阅读 · 0 评论 -
Codeforces Round #582 (Div. 3)--D2. Equalizing by Division (hard version)--位运算||BFS
D2. Equalizing by Division (hard version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between easy and ha...原创 2019-08-31 10:32:21 · 207 阅读 · 0 评论 -
Codeforces Round #182 (Div. 1)--D. Yaroslav and Divisors--树状数组
D. Yaroslav and Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYaroslav has an arrayp = p1, p2, ..., pn(1 ≤ pi ≤ n), ...原创 2019-09-02 18:41:48 · 177 阅读 · 0 评论 -
Codeforces Round #442 (Div. 2)--D. Olya and Energy Drinks--BFS+剪枝
D. Olya and Energy Drinkstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOlya loves energy drinks. She loves them so much that h...原创 2019-09-03 19:57:19 · 115 阅读 · 0 评论 -
POJ 3278Catch That Cow BFS
Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a po...原创 2019-03-10 22:07:56 · 107 阅读 · 0 评论 -
HDU1495 非常可乐 BFS||数论
http://acm.hdu.edu.cn/showproblem.php?pid=1495大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101)毫升 ...原创 2019-02-09 12:41:38 · 147 阅读 · 0 评论 -
Bfs1.4(两点之间最短距离)
按照象棋中马走的方向,判断两点间最短距离或不可到达;http://poj.org/problem?id=2243#include<iostream>#include<queue>#include<cstring>using namespace std;const int maxn=1001+5;int dx[]={-2,-2,-1,-1,1,...原创 2018-10-16 21:55:44 · 710 阅读 · 0 评论 -
Bfs1.5(打印路径)
打印左顶点到右低点最短路径http://poj.org/problem?id=3984输入:0 1 0 0 00 1 0 1 00 0 0 0 00 1 1 1 00 0 0 1 0输出:(0, 0)(1, 0)(2, 0)(2, 1)(2, 2)(2, 3)(2, 4)(3, 4)(4, 4)#include<iostream>...原创 2018-10-16 22:19:20 · 189 阅读 · 0 评论 -
BFS算法HDU - 1312 RED AND BLACK
http://acm.hdu.edu.cn/showproblem.php?pid=1312#include<bits/stdc++.h>using namespace std;int n,m;int ans;int visit[200][200];int dx[]= {-1,1,0,0};int dy[]= {0,0,-1,1};char maps[200][20...原创 2018-11-16 11:21:46 · 139 阅读 · 0 评论 -
广度优先搜索7美式足球
在美式足球中,四分卫负责指挥整只球队的进攻战术和跑位,以及给接球员传球的任务。四分卫是一只球队进攻组最重要的球员,而且一般身体都相对比较弱小,所以通常球队会安排5-7名大汉来保护他,其中站在四分卫前方、排成一线的5名球员称为进攻锋线,他们通常都是135公斤左右的壮汉。<br><imgsrc=../../../data/images/2531-1.jpg><br>...原创 2018-03-24 15:43:23 · 148 阅读 · 0 评论 -
广度优先搜索6之奇怪楼梯
此题比较新奇,可是套路依旧 Problem 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 butt...原创 2018-03-20 23:14:32 · 129 阅读 · 0 评论 -
广度优先搜索5之石油勘探
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 divi...原创 2018-03-18 16:19:32 · 296 阅读 · 0 评论 -
广度优先搜索之天使4
问题:Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M &lt;= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.<br><br...原创 2018-03-13 23:00:39 · 131 阅读 · 0 评论 -
广度优先搜索2
有一个n*m的棋盘(1<n,m<=400),在某个点上有一个马,要求你计算出马到达棋盘上任意一个点最少要走几步输入输出格式输入格式: 一行四个数据,棋盘的大小和马的坐标 输出格式: 一个n*m的矩阵,代表马到达某个点最少要走几步(左对齐,宽5格,不能到达则输出-1)代码如下#include <bits/stdc++....原创 2018-03-11 08:53:31 · 87 阅读 · 0 评论 -
广度优先搜索3
迷宫问题 有一个仅由数字0与1组成的n×n格迷宫。若你位于一格0上,那么你可以移动到相邻4格中的某一格1上,同样若你位于一格1上,那么你可以移动到相邻4格中的某一格0上。你的任务是:对于给定的迷宫,询问从某一格开始能移动到多少个格子 #include<bits/stdc++.h>using namespace std;int mp[2000][200...原创 2018-03-11 16:16:31 · 110 阅读 · 0 评论 -
Find The MultiplePOJ1426(深度优先搜索+无符号整数/广度优先搜索+打表)
http://poj.org/problem?id=14261.#define N 200#include<iostream>using namespace std;#include<cstdio>#include<queue>queue<long long>que;int main(){ for(int i=1;i...原创 2018-11-17 21:05:25 · 129 阅读 · 0 评论 -
周练 广度优先搜索+优先队列
Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison. Angel's friends want to...原创 2018-11-28 20:52:34 · 246 阅读 · 0 评论 -
HDU1548A strange lift广度优先搜索
http://acm.hdu.edu.cn/showproblem.php?pid=1548 A strange lift Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 34037 Accepted Subm...原创 2018-12-10 10:50:42 · 151 阅读 · 0 评论 -
HDU5637 BFS
http://acm.hdu.edu.cn/showproblem.php?pid=5637//先bfs存储res值,查询时直接使用 Problem Description A list of n integers are given. For an integer x you can do the following operations: + let the bin...原创 2019-01-15 11:06:56 · 131 阅读 · 0 评论 -
Bfs算法1.3(一维模板)
给定起点n,m,人可以左移-1、1或向前移动与2倍当前距离,求到m最短时间;#include<iostream>#include<queue>#define INF 1000000;using namespace std;const int maxn=1010;int dx[]= {-1,1,0,0};int n,m;struct Node{ ...原创 2018-10-15 21:47:29 · 181 阅读 · 0 评论