ACM: 图论题 poj 3…
来源:互联网 发布:win7如何安装linux系统 编辑:程序博客网 时间:2024/05/19 00:13
Labyrinth owners are planning to run a contest tomorrow. Severalrunners will be dropped to the room number 1. They will run to theroom number n writing down colors of passages as they runthrough them. The contestant with the shortest sequence of colorsis the winner of the contest. If there are several contestants withthe same sequence length, the one with the ideal path is thewinner. The path is the ideal path if its color sequence is thelexicographically smallest among shortest paths.
Andrew is preparing for the contest. He took a helicopter tourabove New Lostland and made a picture of the labyrinth. Your taskis to help him find the ideal path from the room number 1 to theroom number n that would allow him to win the contest.
Note
A sequence (a1, a2, . . . ,ak) is lexicographically smaller than a sequence(b1, b2, . . . ,bk) if there exists i such thatai < bi, andaj = bj for all j< i.
Input
Output
Sample Input
4 6
1 2 1
1 3 2
3 4 3
2 3 1
2 4 4
3 1 1
Sample Output
2
1 3
题意: 一个图, 求出最短路径长度, 并且输出字典序最小的路径. 因为每条路径有一个
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
#define MAX 110005
#define MAXSIZE 400005
const int INF = (1<<30);
struct node
{
}edges1[MAXSIZE];
struct pNode
{
}edges2[MAXSIZE];
int n, m;
int dist[MAX];
int first1[MAXSIZE], first2[MAXSIZE];
int num1, num2;
bool vis[MAX];
inline int min(int a, int b)
{
}
inline void add1(int u, int v, int color)
{
}
inline void add2(int level, int v)
{
}
void read_graph()
{
}
void spfa()
{
}
void printPath()
{
}
int main()
{
//
}
- ACM: 图论题 poj 3…
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 2240 (floyd + ST…
- ACM: 二分图最佳匹配 图论题 poj 3…
- ACM: 匈牙利算法 图论题 poj 3041 …
- ACM: 差分约束 图论题 poj 2983 sp…
- ACM: 有向欧拉图 图论题 poj 1386 …
- ACM: 图论题 poj 2253 (poj上的dou…
- ACM: 图论题 poj 1135
- ACM: 二分图最大匹配 图论题 poj 2…
- ACM: 图论题 poj 1161 (把图重建成…
- ACM: 图论题 poj 1789 (一次AC的水…
- ACM: 图论题 poj 1125 (题意读好久…
- ACM: 图论题 poj 1062 (邻接矩阵+d…
- ACM: 最小费用最大流 图论题 poj 2…
- ACM: 简单最小生成树 图论题 poj 1…
- ACM: 图论题+记忆DP poj 2662 (边…
- ACM: 动态规划题 poj 3093 0-1背包
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 2923
- 兴趣学习: opencv -- 视频读写, 鼠…
- 兴趣学习: opencv 实现画图程序
- ACM: 图论题 poj 3…
- ACM: 动态规划题 poj&nb…
- ACM: 博弈题 poj 1143 状态压缩
- ACM: 图论题 poj 2186 强连通分量
- ACM: 图论题 poj 3352 双连通题
- ACM: 图论题 poj 3177 同 3352
- Android的自定义控件起步
- dos批处理中%~dp0%的说明
- ACM: 图论题 poj 3308 最大流问题