BAPC 2014 Preliminary 暑假第一场 B.Failing Components

题目链接
As a jury member of the Best Architectural Planning Contest, you are tasked with scoring the
reliability of a system. All systems entered in the contest consist of a number of components
which depend on each other. The reliability of such a system depends on the damage done
by a failing component. Ideally a failing component should have no consequences, but since
most components depend on each other, some other components will usually fail as well.
Most components are somewhat resilient to short failures of the components they depend
on. For example, a database could be unavailable for a minute before the caches expire and
new data must be retrieved from the database. In this case, the caches can survive for a minute
after a database failure, before failing themselves. If a component depends on multiple other
components which fail, it will fail as soon as it can no longer survive the failure of at least
one of the components it depends on. Furthermore no component depends on itself directly,
however indirect self-dependency through other components is possible.
You want to know how many components will fail when a certain component fails, and
how much time passes before all components that will eventually fail, actually fail. This
is difficult to calculate by hand, so you decided to write a program to help you. Given the
description of the system, and the initial component that fails, the program should report how
many components will fail in total, and how much time passes before all those components
have actually failed.
Input
On the first line one positive number: the number of test cases, at most 100. After that per test
case:
• one line with three space-separated integers n, d and c (1 ≤ n ≤ 10 000 and 1 ≤ d ≤
100 000 and 1 ≤ c ≤ n): the total number of components in the system, the number of
dependencies between components, and the initial component that fails, respectively.
• d lines with three space-separated integers a, b and s (1 ≤ a, b ≤ n and a 6= b and
0 ≤ s ≤ 1 000), indicating that component a depends on component b, and can survive
for s seconds when component b fails.
In each test case, all dependencies (a, b) are unique.
Output
Per test case:
• one line with two space-separated integers: the total number of components that will
fail, and the number of seconds before all components that will fail, have actually failed.
4 Problem B: Failing Components
Sample in- and output
样例输入
2
3 2 2
2 1 5
3 2 5
3 3 1
2 1 2
3 1 8
3 2 4
样例输出
2 5
3 6

题意:
哇 读题啊 所以又读错题了,我一直以为是找最小树形图,用朱刘算法。本地过了,但是一直wa。主要是我现在都不知道为什么不能用最小树形图。我们可以根据图以给的最原始的开始点为起点,构造一颗最小树形图。不知道有无大佬可以给我提示一下哪儿有错误。
正解题意: 一个单向图,以组件为点,如果依赖则构造有向边,权值即为时间。从出错的初始组件开始,找到一条最短路径,统计个数并且算出最小权值。Dijkstra

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值