ACM: 图论题 poj 1135
来源:互联网 发布:mac下面的图标怎么换掉 编辑:程序博客网 时间:2024/05/22 00:28
Description
While this is somewhat pointless with only a few dominoes, somepeople went to the opposite extreme in the early Eighties. Usingmillions of dominoes of different colors and materials to fillwhole halls with elaborate patterns of falling dominoes, theycreated (short-lived) pieces of art. In these constructions,usually not only one but several rows of dominoes were falling atthe same time. As you can imagine, timing is an essential factorhere.
It is now your task to write a program that, given such a system ofrows formed by dominoes, computes when and where the last dominofalls. The system consists of several ``key dominoes'' connected byrows of simple dominoes. When a key domino falls, all rowsconnected to the domino will also start falling (except for theones that have already fallen). When the falling rows reach otherkey dominoes that have not fallen yet, these other key dominoeswill fall as well and set off the rows connected to them. Dominorows may start collapsing at either end. It is even possible that arow is collapsing on both ends, in which case the last dominofalling in that row is somewhere between its key dominoes. You canassume that rows fall at a uniform rate.
Input
The following m lines each contain three integers a, b, and l,stating that there is a row between key dominoes a and b that takesl seconds to fall down from end to end.
Each system is started by tipping over key domino number 1.
The file ends with an empty system (with n = m = 0), which shouldnot be processed.
Output
Sample Input
2 1
1 2 27
3 3
1 2 5
1 3 5
2 3 5
0 0
Sample Output
System #1
The last domino falls after 27.0 seconds, at key domino 2.
System #2
The last domino falls after 7.5 seconds, between key dominoes 2 and3.
题意: 多米若骨牌, 从1开始推倒, 计算出最后的到的时间, 和两个关键位置,
解题思路:
代码:
#include<cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 505
const int INF = (1<<29);
int n, m;
int g[MAX][MAX];
double result;
int state1, state2;
int dist[MAX];
bool vis[MAX];
void read_graph()
{
}
int dijkstra(int start)
{
}
int main()
{
//
}
- ACM: 图论题 poj 1135
- ACM: 图论题 poj 3…
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 2240 (floyd + ST…
- ACM: 二分法 数论题 poj 1905
- ACM: 匈牙利算法 图论题 poj 3041 …
- ACM: 差分约束 图论题 poj 2983 sp…
- ACM: 有向欧拉图 图论题 poj 1386 …
- ACM: 图论题 poj 3177 同 3352
- ACM: 图论题 poj 2253 (poj上的dou…
- ACM: 二分图最佳匹配 图论题 poj 3…
- ACM: 二分图最大匹配 图论题 poj 2…
- ACM: 图论题 poj 1161 (把图重建成…
- ACM: 图论题 poj 1789 (一次AC的水…
- ACM: 图论题 poj 1125 (题意读好久…
- ACM: 图论题 poj 1062 (邻接矩阵+d…
- ACM: 匈牙利算法 图论题 poj 3020
- ACM: 动态规划体 toj 1408
- ACM: 训练题 动态规划题 (蛮有意思…
- ACM: 简单 动态规划题 poj 3036
- ACM: 动态规划题 toj 1508
- ACM: 简单 动态规划题 toj 1509 (…
- ACM: 图论题 poj 1135
- ACM: 图论题 poj 1161 (把图重建成…
- spark-graphx新的里程碑GraphDataFrames
- ACM: 闭包问题 图论题 (书上练习)
- ACM: 广搜 图论题 poj 1708
- ACM: 最近公共祖先问题 图论题
- ACM: 无向图的强连通分量 图论题 p…
- ACM: 浙江省赛题目 22:00 ~ 3:00 (…
- 2012年广东ACM省赛赛后总结