Floyd_Warshall POJ 1847 Tram】的更多相关文章

题目传送门 题意:这题题目难懂.问题是A到B最少要转换几次城市.告诉每个城市相连的关系图,默认与第一个之间相连,就是不用转换,其余都要转换. 分析:把第一个城市权值设为0, 其余设为0.然后Floyd跑一下,得到A到B最少转换几次.有点水 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = 1e2 + 5; const int INF =…
POJ 1847 Tram (最短路径) Description Tram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to the one of the rails going out of the intersection. When the tram ent…
POJ 1847 最短路 每个点都有初始指向,问从起点到终点最少要改变多少次点的指向 *初始指向的那条边长度为0,其他的长度为1,表示要改变一次指向,然后最短路 =========高亮!!!==========数组要开n^2的QAQ #include <iostream> #include <cstdio> #include <queue> using namespace std; #define SZ 10005//开n^2的数组!! #define INF 1e9+…
http://poj.org/problem?id=1847 这道题题意不太容易理解,n个车站,起点a,终点b:问从起点到终点需要转换开关的最少次数 开始的那个点不需要转换开关 数据: 3 2 1//第一个数车站总数3,第二个数起点2,第三个数终点1 2 2 3//第一个数有2个点可到达,两个点分别是2(不需要转换开关),3(需要转换开关) 2 3 1 2 1 2可转化为最短路来写,转换开关次数当做最短路径 #include<stdio.h> #include<stdlib.h>…
Tram Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14630 Accepted: 5397 Description Tram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to the o…
Tram 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/N Description Tram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to the one of the rails goi…
Tram Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12005   Accepted: 4365 Description Tram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to t…
Description Tram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to the one of the rails going out of the intersection. When the tram enters the intersection…
题意很好懂,但是不好下手.这里可以把每个点编个号(1-25),看做一个点,然后能够到达即为其两个点的编号之间有边,形成一幅图,然后求最短路的问题.并且pre数组记录前驱节点,print_path()方法可用算法导论上的. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <ve…
题意:给出n个站点,每个站点都有铁路通向其他站点 如果当前要走得路恰好是该站点的开关指向的铁路,则不用扳开关,否则要手动扳动开关,给出起点和终点,问最少需要扳动多少次开关 输入的第一行是n,start,end 接下来的n行,每一行中,第一个数是该站点向外连接的铁路条数, 第二个数是该站点的开关指向的铁路(因为这儿没有读懂= =所以都建不出图来--5555参见这一句话:Switch in the i-th intersection is initially pointing in the dire…