HDU 2612 find a way 【双BFS】】的更多相关文章

HDU.2612 Find a way (BFS) 题意分析 圣诞节要到了,坤神和瑞瑞这对基佬想一起去召唤师大峡谷开开车.百度地图一下,发现周围的召唤师大峡谷还不少,这对基佬纠结着,该去哪一个...坤神:我要去左边的这个(因为离自己比较近 哈哈~)..瑞瑞:我要去右边的这个(因为离自己比较近 嘿嘿~) --..这对基佬闹矛盾了,开车有危险了! 为了不让他们去召唤师大峡谷坑人,riot决定让他们去X召唤师大峡谷,保证他俩所走的路程和最短.每走一个点需要花费11分钟,输出他们一共花费多少时间(最短时…
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…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2612 题意 有两个人 要去一个城市中的KFC 一个城市中有多个KFC 求两个人到哪一个KFC的总时间最少 求出这个最少的总时间 思路 用BFS打一遍表 求出两个人每人到 每个 KFC 的时间 然后 遍历一下 更新答案 AC代码 #include <cstdio> #include <cstring> #include <ctype.h> #include <cstdl…
题目链接:hdu2612 思路:题意是求两个人到某一个KFC花费时间和最小,其实就是求最短距离和,用两个BFS,分别以两个人为起点,分别记录下两人到每个KFC的距离,然后求出最小的和 #include<stdio.h> #include<string.h> #include<queue> #include<algorithm> #define N 205 using namespace std; char map[N][N]; int v[N][N],ans…
Description 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 countryside, but Merceki’s home is in the…
题目: 链接 思路: 用BFS分别以‘Y’和‘M’的位置为起点进行两次搜索,并把这两次的搜索结果在一个二维数组中保存下来,在对地图遍历遇到‘@’更行最小值. PS: 如果用‘Y’和‘M’点分别去搜每个‘@’,这样妥妥的会超时.当时做这个题脑抽的一批……(烦!!!) 另外如果‘Y’和‘M’到不了‘@’这里的值为0,应该把这种情况排除. 代码: //#include <bits/stdc++.h> #include <queue> #include <cstdio> #in…
题目传送门 /* BFS:和UVA_11624差不多,本题就是分别求两个点到KFC的最短路,然后相加求最小值 */ /************************************************ Author :Running_Time Created Time :2015-8-4 19:36:36 File Name :HDOJ_2612.cpp ************************************************/ #include <cstd…
题目代号:HDU 2612 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612 Find a way Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15919    Accepted Submission(s): 5110 Problem Description Pass a year…
HDU 2612 Find a way(找条路) 00 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)   Problem Description - 题目描述 Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to…
<题目链接> 题目大意:两个人分别从地图中的Y 和 M出发,要共同在 @ 处会面(@不止有一处),问这两个人所走距离和的最小值是多少. 解题分析: 就是对这两个点分别进行一次BFS,求出它们到每一个 @ 点的最短距离,然后距离和最小的即为所求(图上一步相当于 11).此题有坑,必须判断两个人是否都能够走到那个@点,如果不能走到,那么那个距离和应该作废. #include<iostream> #include<queue> #include<algorithm>…
Problem Description 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 countryside, but Merceki’s home is…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612 Problem DescriptionPass 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’…
http://acm.hdu.edu.cn/showproblem.php?pid=2612 bfs两次就可将两个人到达所有kfc的时间求出,取两人时间之和最短的即可,这个有点不符合实情,题目应该出两人最大时间最小才对 #include <cstdio> #include <cstring> #include <queue> using namespace std; const int inf=0x3fffffff; char maz[300][301]; int n,…
题目链接: http://poj.org/problem?id=1947 题目大意:两人选择图中一个kfc约会.问两人到达时间之和的最小值. 解题思路: 对于一个KFC,两人的BFS目标必须一致. 于是就有以下的SB行为:记录所有KFC,对于每个KFC,对两人BFS.然后你就会看见红红的TLE. 实际上,只需要两次BFS就可以了,用time_k[0][i]记录a同学到达第i个kfc的时间,time_k[1][i]记录b同学到达第i个kfc的时间. 在一次bfs过程中,记录到达所有kfc的时间.…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612 思路:从两个起点出发,有多个终点,求从两个起点同时能到达的终点具有的最小时间,开两个数组分别保存两个起点到达每一个终点的用时,最后将两个 数组里的时间加起来求最小的一组,必须对应相加,因为终点必须同时到达. #include <iostream> #include <string> #include <cstdio> #include <cmath> #i…
Find a way Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 22390 Accepted Submission(s): 7304 Problem Description Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Lea…
主题链接:Find a Way 题目不难,前几天做,当时准备写双向BFS的,后来处理细节上出了点问题,赶上点事搁置了.今天晚上重写的,没用双向,用了两次BFS搜索,和双向BFS 道理差点儿相同.仅仅是这题有个小坑,须要注意 1.Y不能经过M.M不能经过Y.也就是说有Y和M的格子,能够默觉得是墙 2.必须是Y和M都能到达的KFC才行,仅仅是当中一个到达不行 比例如以下列数据:答案既不是22 也不是 88 而是110,左下角的KFC满座条件 5 5 Y..#@ ...M. ....# ..... @…
之前我写的时候是:每找到一个‘@’就广搜一次,如果这样写有多少个‘@’就会广搜几次,这样就超时了.我队友告诉我应该打个表,这个方法确实不错.因为'Y'和'M'是唯一的,我通过这两个点分别广搜一次,对所有到达‘@’的情况打个表,这样就节省了很多时间.具体看代码吧. #include<cstdio> #include<stdio.h> #include<cstdlib> #include<cmath> #include<iostream> #incl…
Find a way Problem Description 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 countryside, but Mercek…
分别以两个人的家作为起点,bfs求得到每个KFC最短距离.然后枚举每个KFC,求得时间之和的最小值即可. 此题不符合实际情况之处:  通过了一个KFC再去另一个KFC可以吗? 出题人都没好好想过吗? AC代码 #include<cstdio> #include<cstring> #include<algorithm> #include<queue> using namespace std; const int maxn = 200 + 5; int d[2]…
Problem Description 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 countryside, but Merceki’s home is…
Find a way Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3226    Accepted Submission(s): 1045 Problem Description Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally.…
Find a way Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 23967    Accepted Submission(s): 7823 Problem Description Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally…
题目链接 双端队列跑边,颜色相同的边之间的花费为0,放进队首:不同的花费为1,放进队尾. 用Dijkstra+常数优化也能过 #include<bits/stdc++.h> using namespace std; typedef long long ll; ,mod=1e9+; int n,m,hd[N],ne,dp[N]; struct E {int v,c,nxt;} e[N]; void addedge(int u,int v,int c) {e[ne]= {v,c,hd[u]},hd…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2612 Find a way Description 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.Yifen…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2612 Find a way Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6718    Accepted Submission(s): 2236 Problem Description Pass a year learning in Han…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2717 Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12615    Accepted Submission(s): 3902 Problem Description Farmer John has been…
Collect More Jewels Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6713    Accepted Submission(s): 1558 Problem Description It is written in the Book of The Lady: After the Creation, the cruel…
http://acm.hdu.edu.cn/showproblem.php?pid=5876 Sparse Graph Problem Description   In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are not adjacent in…
http://acm.hdu.edu.cn/showproblem.php?pid=1728 逃离迷宫 Problem Description   给定一个m × n (m行, n列)的迷宫,迷宫中有两个位置,gloria想从迷宫的一个位置走到另外一个位置,当然迷宫中有些地方是空地,gloria可以穿越,有些地方是障碍,她必须绕行,从迷宫的一个位置,只能走到与它相邻的4个位置中,当然在行走过程中,gloria不能走到迷宫外面去.令人头痛的是,gloria是个没什么方向感的人,因此,她在行走过程中…