CF1307G.Cow and Exercise

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Farmer John is obsessed with making Bessie exercise more!

Bessie is out grazing on the farm, which consists of nn fields connected by mm directed roads. Each road takes some time wiw_i to cross. She is currently at field 11 and will return to her home at field nn at the end of the day.

Farmer John has plans to increase the time it takes to cross certain roads. He can increase the time it takes to cross each road by a nonnegative amount, but the total increase cannot exceed xix_i for the ii -th plan.

Determine the maximum he can make the shortest path from 11 to nn for each of the qq independent plans.

输入格式

The first line contains integers nn and mm ( 2n502 \le n \le 50 , 1mn(n1)1 \le m \le n \cdot (n-1) ) — the number of fields and number of roads, respectively.

Each of the following mm lines contains 33 integers, uiu_i , viv_i , and wiw_i ( 1ui,vin1 \le u_i, v_i \le n , 1wi1061 \le w_i \le 10^6 ), meaning there is an road from field uiu_i to field viv_i that takes wiw_i time to cross.

It is guaranteed that there exists a way to get to field nn from field 11 . It is guaranteed that the graph does not contain self-loops or parallel edges. It is possible to have a road from uu to vv and a road from vv to uu .

The next line contains a single integer qq ( 1q1051 \le q \le 10^5 ), the number of plans.

Each of the following qq lines contains a single integer xix_i , the query ( 0xi1050 \le x_i \le 10^5 ).

输出格式

For each query, output the maximum Farmer John can make the shortest path if the total increase does not exceed xix_i .

Your answer is considered correct if its absolute or relative error does not exceed 10610^{-6} .

Formally, let your answer be aa , and the jury's answer be bb . Your answer is accepted if and only if abmax(1,b)106\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6} .

输入输出样例

  • 输入#1

    3 3
    1 2 2
    2 3 2
    1 3 3
    5
    0
    1
    2
    3
    4

    输出#1

    3.0000000000
    4.0000000000
    4.5000000000
    5.0000000000
    5.5000000000
首页