zoukankan      html  css  js  c++  java
  • zoj 2532(网络流)

    先用网络流求出残留网络,然后根据题意要求出增大那些边的容量使得总的流量最大, 我的做法比较水, 枚举残余网络中的饱和边,然后在bfs找增广路,如果找的到增广路,那么说明增加这条边的容量可是使得最大流变大。

    还有一种更简单的方法, 在求出残余网络后,从源点和汇点分别bfs一次,如果一条边的一端顶点可以从源点到达,另一端的顶点可以被汇点到达,那么说明增加这条边的容量可以增大总的流量。

    Internship

    Time Limit: 5 Seconds      Memory Limit: 32768 KB

    CIA headquarter collects data from across the country through its classified network. They have been using optical fibres long before it's been deployed on any civilian projects. However they are still under a lot pressure recently because the data are growing rapidly. As a result they are considering upgrading the network with new technologies that provide a few times wider bandwidth. In the experiemental stage, they would like to upgrade one segment of their original network in order to see how it performs. And as a CIA intern it's your responsibility to investigate which segment could actually help increase the total bandwidth the headquarter receives, suppose that all the cities have infinite data to send and the routing algorithm is optimized. As they have prepared the data for you in a few minutes, you are told that they need the result immediately. Well, practically immediately.

    Input

    Input contains multiple test cases. First line of each test case contains three integers n, m and l, they represent the number of cities, the number of relay stations and the number of segments. Cities will be referred to as integers from 1 to n, while relay stations use integers from n+1 to n+m. You can saves assume that n + m <= 100, l <= 1000 (all of them are positive). The headquarter is identified by the integer 0.

    The next l lines hold a segment on each line in the form of a b c, where a is the source node and b is the target node, while c is its bandwidth. They are all integers where a and b are valid identifiers (from 0 to n+m). c is positive. For some reason the data links are all directional.

    The input is terminated by a test case with n = 0. You can safely assume that your calculation can be housed within 32-bit integers.

    Output

    For each test print the segment id's that meets the criteria. The result is printed in a single line and sorted in ascending order, with a single space as the separator. If none of the segment meets the criteria, just print an empty line. The segment id is 1 based not 0 based.

    Sample Input

    2 1 3
    1 3 2
    3 0 1
    2 0 1
    2 1 3
    1 3 1
    2 3 1
    3 0 2
    0 0 0
    

    Sample Output

    2 3
    <hey here is an invisible empty line>
    

    Author: WU, Jiazhi
    Source: CYJJ's Funny Contest #3, Having Fun in Summer

     

  • 相关阅读:
    如何抓住用户痛点做产品?
    分析需求场景对产品设计的意义
    【用户分析-用户场景】这TM才是产品思维!
    WebUploader实现浏览器端大文件分块上传
    npm 安装包报错 rollbackFailedOptional
    PAT 甲级 1074 Reversing Linked List (25 分)(链表部分逆置,结合使用双端队列和栈,其实使用vector更简单呐)...
    PAT 甲级 1071 Speech Patterns (25 分)(map)
    P3370 【模板】字符串哈希
    PageRank算法原理与Python实现
    PAT-2019年冬季考试-甲级 7-4 Cartesian Tree (30分)(最小堆的中序遍历求层序遍历,递归建树bfs层序)...
  • 原文地址:https://www.cnblogs.com/chenhuan001/p/3106891.html
Copyright © 2011-2022 走看看