FZU2150 :Fire Game (双起点BFS)】的更多相关文章

传送门:点我 题意:“#”是草,"."是墙,询问能不能点燃俩地方,即点燃俩“#”,把所有的草烧完,如果可以,那么输出最小需要的时间,如果不行输出-1 思路:暴力BFS,看到n和m都不大,直接把每个“#”都存下来,每次加入2个点进广搜搜能否烧完,然后更新ans即可. #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <ct…
<题目链接> 题目大意: 两个熊孩子在n*m的平地上放火玩,#表示草,两个熊孩子分别选一个#格子点火,火可以向上向下向左向右在有草的格子蔓延,点火的地方时间为0,蔓延至下一格的时间依次加一.求烧完所有的草需要的最少时间.如不能烧完输出-1. 解题分析: 暴力枚举两个起点,然后用BFS求出这两个火源能够蔓延到最远的草地所花的时间,在那些能够烧完所有草地的情况中,选择用时最少的. #include <iostream> #include <cstring> #include…
Find a way Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16184    Accepted Submission(s): 5194 Problem Description Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally…
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 the maze and which squares of the maze are on fire, you…
题目: 两个熊孩子在n*m的平地上放火玩,#表示草,两个熊孩子分别选一个#格子点火,火可以向上向下向左向右在有草的格子蔓延,点火的地方时间为0,蔓延至下一格的时间依次加一.求烧完所有的草需要的最少时间.如不能烧完输出-1. 输入: 第一行,输入一个T,表示有T组测试数据. 每组数据由一个n,m分别表示行列 1 <= T <=100, 1 <= n <=10, 1 <= m <=10 输出: 输出最少需要的时间> 样例: 分析:双起点的BFS,本质上就是枚举两个起点…
题意,10*10的地图,有若干块草地“#”,草地可以点燃,并在一秒后点燃相邻的草地.有墙壁‘·‘阻挡.初始可以从任意两点点火.问烧完最短的时间.若烧不完输出-1. 题解:由于100的数据量,直接暴力.枚举两个起点,推入队列,然后bfs.烧完就返回深度,更新一个min值. 坑:(帮同学照bug) return t.step+1;bfs后没有算上最后一步 ac代码 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cs…
题目链接:https://vjudge.net/problem/FZU-2150 Problem 2150 Fire Game Accept: 2702    Submit: 9240 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N row…
题意:就是选两个点出发,只能走草坪,看能不能走完所有的草坪 分析:由于数据范围很小,所有枚举这两个点,事先将所有的草坪点存起来,然后任选两个点走,(两个点可以是同一个点) 然后BFS就行了 注:无解的情况很好做,事先深搜判连通块的个数就好,大于2就无解(代码比较烂) #include<cstdio> #include<algorithm> #include<iostream> #include<cstring> #include<cmath> #…
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2671 题目: 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 esca…
传送门: http://acm.csu.edu.cn/csuoj/problemset/problem?pid=2031 Description The Barareh village is on fire due to the attack of the virtual enemy. Several places are already on fire and the fire is spreading fast to other places. Khorzookhan who is the…