POJ 3691 Nubulsa Expo 全局最小割
来源:互联网 发布:西南交通大学网络教学 编辑:程序博客网 时间:2024/06/06 09:52
Nubulsa Expo
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1341 Accepted Submission(s): 630
Problem Description
You may not hear about Nubulsa, an island country on the Pacific Ocean. Nubulsa is an undeveloped country and it is threatened by the rising of sea level. Scientists predict that Nubulsa will disappear by the year of 2012. Nubulsa government wants to host the 2011 Expo in their country so that even in the future, all the people in the world will remember that there was a country named “Nubulsa”.
As you know, the Expo garden is made up of many museums of different countries. In the Expo garden, there are a lot of bi-directional roads connecting those museums, and all museums are directly or indirectly connected with others. Each road has a tourist capacity which means the maximum number of people who can pass the road per second.
Because Nubulsa is not a rich country and the ticket checking machine is very expensive, the government decides that there must be only one entrance and one exit. The president has already chosen a museum as the entrance of the whole Expo garden, and it’s the Expo chief directory Wuzula’s job to choose a museum as the exit.
Wuzula has been to the Shanghai Expo, and he was frightened by the tremendous “people mountain people sea” there. He wants to control the number of people in his Expo garden. So Wuzula wants to find a suitable museum as the exit so that the “max tourists flow” of the Expo garden is the minimum. If the “max tourist flow” is W, it means that when the Expo garden comes to “stable status”, the number of tourists who enter the entrance per second is at most W. When the Expo garden is in “stable status”, it means that the number of people in the Expo garden remains unchanged.
Because there are only some posters in every museum, so Wuzula assume that all tourists just keep walking and even when they come to a museum, they just walk through, never stay.
As you know, the Expo garden is made up of many museums of different countries. In the Expo garden, there are a lot of bi-directional roads connecting those museums, and all museums are directly or indirectly connected with others. Each road has a tourist capacity which means the maximum number of people who can pass the road per second.
Because Nubulsa is not a rich country and the ticket checking machine is very expensive, the government decides that there must be only one entrance and one exit. The president has already chosen a museum as the entrance of the whole Expo garden, and it’s the Expo chief directory Wuzula’s job to choose a museum as the exit.
Wuzula has been to the Shanghai Expo, and he was frightened by the tremendous “people mountain people sea” there. He wants to control the number of people in his Expo garden. So Wuzula wants to find a suitable museum as the exit so that the “max tourists flow” of the Expo garden is the minimum. If the “max tourist flow” is W, it means that when the Expo garden comes to “stable status”, the number of tourists who enter the entrance per second is at most W. When the Expo garden is in “stable status”, it means that the number of people in the Expo garden remains unchanged.
Because there are only some posters in every museum, so Wuzula assume that all tourists just keep walking and even when they come to a museum, they just walk through, never stay.
Input
There are several test cases, and the input ends with a line of “0 0 0”.
For each test case:
The first line contains three integers N, M and S, representing the number of the museums, the number of roads and the No. of the museum which is chosen as the entrance (all museums are numbered from 1 to N). For example, 5 5 1 means that there are 5 museums and 5 roads connecting them, and the No. 1 museum is the entrance.
The next M lines describe the roads. Each line contains three integers X, Y and K, representing the road connects museum X with museum Y directly and its tourist capacity is K.
Please note:
1<N<=300, 0<M<=50000, 0<S,X,Y<=N, 0<K<=1000000
For each test case:
The first line contains three integers N, M and S, representing the number of the museums, the number of roads and the No. of the museum which is chosen as the entrance (all museums are numbered from 1 to N). For example, 5 5 1 means that there are 5 museums and 5 roads connecting them, and the No. 1 museum is the entrance.
The next M lines describe the roads. Each line contains three integers X, Y and K, representing the road connects museum X with museum Y directly and its tourist capacity is K.
Please note:
1<N<=300, 0<M<=50000, 0<S,X,Y<=N, 0<K<=1000000
Output
For each test case, print a line with only an integer W, representing the “max tourist flow” of the Expo garden if Wuzula makes the right choice.
Sample Input
5 5 11 2 52 4 61 3 73 4 35 1 100 0 0
Sample Output
8给出一个无向图G和一个源点s问以任意一点为汇点的最大流的最小值,由最大流最小割定理看出需要求全局最小割。#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;const int maxm = 505;const int inf = 0x3f3f3f3f;int v[maxm], d[maxm], g[maxm][maxm];bool vis[maxm];int sw(int n){int rev = inf;for (int i = 1;i <= n;i++) v[i] = i;while (n > 1){int k = 1, pre = 1;memset(vis, 0, sizeof(vis));memset(d, 0, sizeof(d));for (int i = 2;i <= n;i++){k = -1;for (int j = 2;j <= n;j++){if (!vis[v[j]]){d[v[j]] += g[v[pre]][v[j]];if (k == -1 || d[v[k]] < d[v[j]])k = j;}}vis[v[k]] = true;if (i == n){rev = min(rev, d[v[k]]);for (int j = 1;j <= n;j++){g[v[pre]][v[j]] += g[v[j]][v[k]];g[v[j]][v[pre]] += g[v[j]][v[k]];}v[k] = v[n--];}pre = k;}}return rev;}int main(){int n, m, x, y, z, s;while (scanf("%d%d%d", &n, &m, &s) && n != 0){memset(g, 0, sizeof(g));for (int i = 1;i <= m;i++){scanf("%d%d%d", &x, &y, &z);g[x][y] += z;g[y][x] += z;}printf("%d\n", sw(n));}return 0;}
阅读全文
0 0
- POJ 3691 Nubulsa Expo 全局最小割
- HDU 3691 Nubulsa Expo (全局最小割)
- Nubulsa Expo. 全局最小割
- HDU 3691 Nubulsa Expo(全局最小割Stoer_Wagn)
- HDU 3691 Nubulsa Expo(全局最小割)
- HDU 3691 Nubulsa Expo(全局最小割)(10福州B题)#by zh
- Stoer-Wagner无向图全局最小割(hduoj 3691 Nubulsa Expo)
- HDU 3691 Nubulsa Expo(SW算法求最小割)
- Hdu 3691 Nubulsa Expo(无向图最小割)
- UVALive 5099 Nubulsa Expo 全局最小割 非网络流 n^3
- HDU 3691 Nubulsa Expo
- HDU 3691 Nubulsa Expo
- poj-2914-全局最小割
- hdu3691Nubulsa Expo(Stoer-Wagner求无向图全局最小割)
- HDU 3691 全局最小割
- POJ 2914 Minimum Cut 全局最小割
- poj 2914 Minimum Cut(全局最小割)
- POJ 2914 Minimum Cut 全局最小割
- 8_9教务管理系统
- Ensemble 概念入门
- 如何使用ARMS配置tengine的日志监控
- phpcms 后台登陆及版权修改问题
- 无人自助便利店采用射频识别技术 30秒钟就能完成付款
- POJ 3691 Nubulsa Expo 全局最小割
- Python高级教程之私有化
- java.util.HashMap
- IntelliJ IDEA下的使用git
- 阿里云短信服务api
- 使用ueditor视频无法上传的问题
- 神经网络之激励函数(Activation Function)
- canvas中save和store函数的用法
- ACM 数论 Maximum GCD