最短路
c201904
本人为重庆市某中学的信息竞赛生,信息长期保持在年级第一(24个人),希望各位大牛多多关心!
展开
-
UVA 11374 Air Express
这道题其实就是这个意思:给你m条路,可以随便走;再给你K条路,这K条路一共只能走一次(可以不走),问从A到B最快要多久. 这道题,其实是道水题,可以参考刘汝佳的蓝书P330。我们从A为起点,做一次单源最短路径,把点X离A的距离记为dis[x][0],然后再以B为起点,做一次单源最短路径,把点X离B的距离记为dis[x][1]。我们设这K条路中任意一条路为x-y,长度为z且经过这条路,...原创 2018-02-10 14:28:49 · 130 阅读 · 0 评论 -
Fire Game
这道题说白了,其实就是最短路径问题,果断用宽搜,但是我们这里要注意的是,这道题是两个起点的宽搜,两个同时搜,而不是分开搜,我本人就是因为这个错误而做了很久的#include<iostream>#include<cstring>#include<queue>using namespace std;const int maxn=20;const int i...原创 2017-07-28 08:19:06 · 171 阅读 · 0 评论 -
Prime Path
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 of secu...原创 2017-07-28 08:04:34 · 173 阅读 · 0 评论 -
POJ-2251 Dungeon Master
这道题呢其实就是一个迷宫问题,只不过从二维变成了三维而已首先呢这道题是用宽搜做的,可以从其数据范围看出我本人一开始用深搜做,然后一直超时,看了数据范围以后才用的宽搜(其实最短路时是最好用宽搜的)#include<iostream>#include<queue>using namespace std;queue<int>p1;//宽搜的队列queue&...原创 2017-07-27 20:44:09 · 282 阅读 · 0 评论 -
POJ-3278 Catch that cow
这道题是道典型的宽搜问题,我们可以从它的数据量就可以看出深搜要超时,并且最短路要用宽搜。#include<iostream> #include<queue> using namespace std; queue<int>sm;//宽搜用队列 int d[200001]={0},start,end;//d[]代表走到当前点需要的最少步数 int sear...原创 2017-07-27 20:47:11 · 459 阅读 · 0 评论