CF457E.Flow Optimality

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Input will begin with two integers nn and mm ( 2<=n<=2000002<=n<=200000 ; 0<=m<=2000000<=m<=200000 ), the number of nodes and number of known links in the network, respectively. Following this are mm lines with four integers each: ff , tt , ww , bb ( 1<=f<=n; 1<=t<=n; ft; 1<=w<=100; 0<=b<=1001<=f<=n; 1<=t<=n; f≠t; 1<=w<=100; 0<=b<=100 ). This indicates there is a link between nodes ff and tt with weight ww and carrying bb bandwidth. The direction of bandwidth is from ff to tt .

输入格式

If the intern's solution is definitely not optimal, print "BAD xx ", where xx is the first link in the input that violates the optimality of the solution. If the intern's solution may be optimal, print the efficiency of the solution if it can be determined rounded to the nearest integer, otherwise print "UNKNOWN".

输出格式

Although the known weights and bandwidths happen to always be integers, the weights and bandwidths of the remaining links are not restricted to integers.

输入输出样例

  • 输入#1

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

    输出#1

    6
    
  • 输入#2

    5 5
    2 3 1 1
    3 4 1 1
    4 2 1 1
    1 5 1 1
    1 5 100 100
    

    输出#2

    BAD 3
    
  • 输入#3

    6 4
    1 3 31 41
    1 5 59 26
    2 6 53 58
    4 6 97 93
    

    输出#3

    UNKNOWN
    
  • 输入#4

    7 5
    1 7 2 1
    2 3 1 1
    4 5 1 0
    6 1 10 0
    1 3 1 1
    

    输出#4

    BAD 4
    

说明/提示

Although the known weights and bandwidths happen to always be integers, the weights and bandwidths of the remaining links are not restricted to integers.

首页