
BFS宽度优先搜索
文章平均质量分 83
RJ28
小学生
展开
-
Codeforces Round #354 (Div. 2) D. Theseus and labyrinth (BFS)
Theseus has just arrived to Crete to fight Minotaur. He found a labyrinth that has a form of a rectangular field of sizen × m and consists of blocks of size1 × 1.Each block of the labyrinth has原创 2016-05-26 20:47:14 · 511 阅读 · 0 评论 -
Hdu-5335 Walk Out (BFS+贪心)
Problem DescriptionIn an n∗mmaze(迷失), the right-bottom corner is the exit (position(n,m) is the exit). In every position of this maze, there is either a 0 or a 1 written on it.An exp原创 2016-05-30 17:04:56 · 437 阅读 · 0 评论 -
Codeforces Round #361 (Div. 2) D. Friends and Subsequences (二分+RMQ)
Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows?原创 2016-07-18 22:27:51 · 597 阅读 · 0 评论 -
UVALive 7155 Keyboarding(BFS)
题意:给定一个r*c的键盘,键盘由字母和数字还有一些符号的按键组成,键盘光标的起始位置在左上角,每次移动可以朝上下左右四个方向跳到一个和当前位置字符不同的按键处,给定一串长字符,问至少要按多少次键盘。分析:直接BFS,f[i][j][k]表示当前在(i,j)位置,已经按了k个键的最小值。#include#include#include#include#include原创 2016-09-03 19:03:40 · 508 阅读 · 0 评论 -
Codeforces Round #407 (Div. 1) C. The Great Mixing(bfs)
Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration . Today, on the party in honour of Sergiy原创 2017-04-01 22:21:12 · 582 阅读 · 0 评论 -
UVALive - 7042 The Problem to Make You Happy(博弈/bfs)
分析: 之前没怎么做过博弈相关的题目,一开始还以为是道复杂的分类讨论,设状态i,j,k表示当前Alice在i点Bob再j点且这一步轮到Alice/Bob操作,若dp[i][j][k]为1则表示Bob必败,那么我们考虑边界必败状态,一是两个点重叠在一起,二是现在轮到Bob操作而且Bob到了一个出度为0的点,有了这些状态后我们可以BFS出所有的必败点,根据题意那么剩下的点就一定是必胜点了。原创 2017-10-18 19:51:05 · 396 阅读 · 0 评论