青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 18,  comments - 5,  trackbacks - 0
一、題目描述

Description

Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainage ditches so that Bessie's clover patch is never covered in water. Instead, the water is drained to a nearby stream. Being an ace engineer, Farmer John has also installed regulators at the beginning of each ditch, so he can control at what rate water flows into that ditch.
Farmer John knows not only how many gallons of water each ditch can transport per minute but also the exact layout of the ditches, which feed out of the pond and into each other and stream in a potentially complex network.
Given all this information, determine the maximum rate at which water can be transported out of the pond and into the stream. For any given ditch, water flows in only one direction, but there might be a way that water can flow in a circle.

Input

The input includes several cases. For each case, the first line contains two space-separated integers, N (0 <= N <= 200) and M (2 <= M <= 200). N is the number of ditches that Farmer John has dug. M is the number of intersections points for those ditches. Intersection 1 is the pond. Intersection point M is the stream. Each of the following N lines contains three integers, Si, Ei, and Ci. Si and Ei (1 <= Si, Ei <= M) designate the intersections between which this ditch flows. Water will flow through this ditch from Si to Ei. Ci (0 <= Ci <= 10,000,000) is the maximum rate at which water will flow through the ditch.

Output

For each case, output a single integer, the maximum rate at which water may emptied from the pond.

Sample Input

5 4
1 2 40
1 4 20
2 4 20
2 3 30
3 4 10

Sample Output

50

二、分析
   其實就是以點1為s,以點m為t,求最大流,但是要注意輸入的路徑可以重復(見代碼30行),使用Edmonds-Karp算法,具體算法:最大流問題
三、代碼
 1#include<iostream>
 2#include<queue>
 3using namespace std;
 4#define MAXM 201
 5int m, n;
 6int si, ei, ci;
 7int c[MAXM][MAXM];
 8int f[MAXM][MAXM];
 9int cf[MAXM][MAXM];
10bool visit[MAXM];
11int p[MAXM];
12struct node
13{
14    int v, cf;
15    void set(int vv, int ccf)
16    {
17        v = vv; cf = ccf;
18    }

19}
;
20int main()
21{
22    while(scanf("%d%d"&n, &m) != EOF)
23    {
24        memset(c, 0sizeof(c));
25        memset(f, 0sizeof(f));
26        memset(cf, 0sizeof(cf));
27        while(n--)
28        {
29            scanf("%d%d%d"&si, &ei, &ci);
30            c[si][ei] += ci;
31            cf[si][ei] = c[si][ei];
32        }

33        bool flag = true//用于表示是否找到增廣路
34        while(flag)
35        {
36            flag = false;
37            memset(visit, 0sizeof(visit));
38            queue<node> q;
39            node temp;
40            temp.set(1, INT_MAX);
41            p[1= 0;
42            q.push(temp); visit[1= true;
43            while(!q.empty()) //廣度優先搜索
44            {
45                node temp = q.front(); q.pop();
46                for(int i=1; i<=m; i++)
47                {
48                    if(temp.v == i || visit[i] || cf[temp.v][i] == 0)
49                        continue;
50                    node newNode; 
51                    newNode.set(i, min(temp.cf, cf[temp.v][i]));
52                    p[i] = temp.v;
53                    q.push(newNode);
54                    visit[i] = true;
55                    if(i == m)
56                    {
57                        flag = true//找到增廣路
58                        break;
59                    }

60                }

61                if(flag)
62                    break;
63            }

64            if(flag)
65            {
66                int mincf = q.back().cf;
67                int v1 = p[m], v2 = m;
68                while(v1 != 0)
69                {
70                    f[v1][v2] += mincf; //修改流
71                    f[v2][v1] = -f[v1][v2];
72                    cf[v1][v2] = c[v1][v2] - f[v1][v2]; //修改殘留容量
73                    cf[v2][v1] = c[v2][v1] - f[v2][v1];
74                    v2 = v1;
75                    v1 = p[v1];
76                }

77            }

78        }

79        int res = 0;
80        for(int i=2; i<=m; i++//計算最大流
81            res += f[1][i];
82        printf("%d\n", res);
83    }

84}
posted on 2009-06-23 19:38 Icyflame 閱讀(2555) 評論(2)  編輯 收藏 引用 所屬分類: 解題報告
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产一区二区精品| 久久久999精品免费| 欧美另类久久久品| 欧美1区2区视频| 免费看成人av| 欧美精品日韩综合在线| 欧美激情一区二区三区不卡| 欧美国产一区视频在线观看| 欧美日韩精品免费观看视一区二区| 欧美国产另类| 国产精品扒开腿做爽爽爽视频| 欧美日韩一区免费| 国产精品午夜国产小视频| 国产美女精品一区二区三区 | 欧美大胆a视频| 亚洲成色777777女色窝| 欧美在线关看| 麻豆久久婷婷| 亚洲日本免费| 亚洲欧美日韩中文视频| 久久激情五月丁香伊人| 欧美成人在线影院| 国产精品亚洲综合天堂夜夜| 在线视频成人| 亚洲欧美国产不卡| 免费欧美网站| 中文日韩在线视频| 美女精品国产| 国产精品综合网站| 91久久在线观看| 亚洲欧美国产日韩天堂区| 久久九九全国免费精品观看| 最近看过的日韩成人| 欧美亚洲一级| 国产精品v片在线观看不卡| 黄色影院成人| 亚洲一区国产精品| 亚洲国产精品t66y| 午夜精品亚洲| 欧美片在线观看| 在线成人亚洲| 欧美在线视频导航| 日韩亚洲欧美成人一区| 久久一区亚洲| 国产日本欧洲亚洲| 亚洲视频在线观看三级| 91久久国产精品91久久性色| 国产精品久久久久久亚洲毛片 | 欧美日韩免费观看一区二区三区 | 韩国三级在线一区| 亚洲午夜激情在线| 亚洲老司机av| 国产亚洲午夜| 噜噜噜躁狠狠躁狠狠精品视频| 亚洲高清一区二区三区| 久久九九电影| 一本色道久久综合狠狠躁篇的优点 | 精品99一区二区三区| 国产亚洲欧洲| 久久亚洲欧洲| 老牛嫩草一区二区三区日本| 国产日韩一区欧美| 日韩视频不卡| 国产精品视频免费| 亚洲精选中文字幕| 亚洲永久精品国产| 欧美日本中文| 91久久国产精品91久久性色| 亚洲一区二区精品| 欧美激情一二区| 在线视频亚洲欧美| 欧美一区日本一区韩国一区| 亚洲国产一区视频| 欧美大片在线观看一区| 午夜日本精品| 午夜影视日本亚洲欧洲精品| 欧美/亚洲一区| 亚洲片区在线| 欧美一级网站| 欧美激情第五页| 亚洲少妇最新在线视频| 久久人人97超碰精品888| 日韩午夜av电影| 亚洲激情综合| 欧美激情视频网站| 99在线精品免费视频九九视| 亚洲国产日韩欧美在线99| 欧美激情精品久久久久久变态| 亚洲国产天堂久久综合网| 欧美jizz19性欧美| 欧美韩日亚洲| 性欧美大战久久久久久久久| 欧美在线视频在线播放完整版免费观看| 国产视频一区欧美| 免费欧美在线视频| 欧美日韩美女在线| 欧美中文字幕不卡| 亚洲欧美国产制服动漫| 六月婷婷一区| 久久精品女人天堂| 国产乱肥老妇国产一区二| 亚洲在线视频观看| 亚洲高清一区二| 黄色成人av网站| 一二三区精品福利视频| 欧美xart系列高清| 欧美亚洲一区二区三区| 欧美激情一二三区| 免费一级欧美片在线观看| 欧美成人免费va影院高清| 亚洲欧美bt| 欧美乱大交xxxxx| 欧美成人午夜免费视在线看片| 欧美视频网址| 久久久久久亚洲精品杨幂换脸| 亚洲一区二区三区乱码aⅴ蜜桃女 亚洲一区二区三区乱码aⅴ | 免费欧美电影| 极品日韩av| 国产视频一区二区三区在线观看| 久久久久免费观看| 久久久国产精品一区二区中文| 国内成+人亚洲+欧美+综合在线| 欧美日韩一区二区三区高清| 日韩视频免费| 亚洲欧美日韩一区二区在线| 亚洲欧美视频在线观看| 久久久美女艺术照精彩视频福利播放 | 久久久久久综合| 一本色道久久综合亚洲精品高清 | 国产精品国产三级国产专区53 | 亚洲一区二区三区午夜| 日韩视频第一页| 久久亚洲私人国产精品va| 久久久久.com| 国产一区视频网站| 欧美一区二区视频观看视频| 欧美与欧洲交xxxx免费观看| 国产精品乱码妇女bbbb| 亚洲精品一品区二品区三品区| 亚洲人成绝费网站色www| 久久女同精品一区二区| 久久综合网络一区二区| 精品999在线播放| 久久综合一区| 亚洲国产精品专区久久| 亚洲精品国产精品国自产在线| 麻豆成人综合网| 亚洲国产精品va在看黑人| 日韩西西人体444www| 欧美成人小视频| 亚洲日本理论电影| 亚洲免费综合| 国产欧美日韩精品一区| 欧美一区二区三区免费视| 久久婷婷成人综合色| 在线精品高清中文字幕| 欧美高清一区| 中文无字幕一区二区三区| 性欧美大战久久久久久久免费观看| 亚洲国产日韩精品| 性欧美18~19sex高清播放| 欧美在线视频a| 在线精品国产欧美| 欧美精品久久99| 亚洲主播在线播放| 免费看的黄色欧美网站| 在线一区二区三区做爰视频网站| 欧美视频日韩| 久久久成人精品| 99精品免费视频| 久久伊人精品天天| 一区二区三区视频在线观看| 国产日韩av一区二区| 蜜月aⅴ免费一区二区三区| 9i看片成人免费高清| 久久久一二三| 亚洲一级在线| 亚洲国内精品| 国产三级精品在线不卡| 欧美精品亚洲精品| 欧美亚洲一区二区三区| 亚洲人在线视频| 久久久夜色精品亚洲| 一区二区三区国产盗摄| 黄网站色欧美视频| 欧美视频第二页| 毛片av中文字幕一区二区| 亚洲女同精品视频| 亚洲精品视频在线播放| 久久免费国产精品| 亚洲一区二区3| 日韩五码在线| 亚洲国产欧美国产综合一区| 国产精品资源在线观看| 欧美激情精品久久久久久蜜臀| 欧美自拍丝袜亚洲| 亚洲深夜激情| 亚洲精品自在久久| 亚洲国产天堂久久综合| 美女网站久久|