博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 1966(网络流求最小割集)
阅读量:6525 次
发布时间:2019-06-24

本文共 2560 字,大约阅读时间需要 8 分钟。

狠狠的复杂度 n*n*n*n*m 。。。 你是在开玩笑嘛。。

求最小割集的办法,枚举两个不相邻的点分别作为源点和汇点, 看流过的流量为多少, 为了体现一个点只能用一次所有每个点要拆成两个点

 

Cable TV Network
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 3424   Accepted: 1593

Description

The interconnection of the relays in a cable TV network is bi-directional. The network is connected if there is at least one interconnection path between each pair of relays present in the network. Otherwise the network is disconnected. An empty network or a network with a single relay is considered connected. The safety factor f of a network with n relays is: 
1. n, if the net remains connected regardless the number of relays removed from the net. 
2. The minimal number of relays that disconnect the network when removed. 
For example, consider the nets from figure 1, where the circles mark the relays and the solid lines correspond to interconnection cables. The network (a) is connected regardless the number of relays that are removed and, according to rule (1), f=n=3. The network (b) is disconnected when 0 relays are removed, hence f=0 by rule (2). The network (c) is disconnected when the relays 1 and 2 or 1 and 3 are removed. The safety factor is 2.

Input

Write a program that reads several data sets from the standard input and computes the safety factor for the cable networks encoded by the data sets. Each data set starts with two integers: 0<=n<=50,the number of relays in the net, and m, the number of cables in the net. Follow m data pairs (u,v), u < v, where u and v are relay identifiers (integers in the range 0..n-1). The pair (u,v) designates the cable that interconnects the relays u and v. The pairs may occur in any order.Except the (u,v) pairs, which do not contain white spaces, white spaces can occur freely in input. Input data terminate with an end of file and are correct.

Output

For each data set, the program prints on the standard output, from the beginning of a line, the safety factor of the encoded net.

Sample Input

0 01 03 3 (0,1) (0,2) (1,2)2 05 7 (0,1) (0,2) (1,3) (1,2) (1,4) (2,3) (3,4)

Sample Output

01302

Hint

The first data set encodes an empty network, the second data set corresponds to a network with a single relay, and the following three data sets encode the nets shown in figure 1.

Source

 

 

#include 
#include
#include
using namespace std;#define N 60#define INF 0x3ffffffstruct node{ int to,next,w;}edge[N*N*N];int cnt,pre[2*N];int g[N][N];int n,m;int s,t;int num;int mark[N];int tt;int gap[2*N],lv[2*N];void dfs(int k){ num++; mark[k]=1; for(int i=0;i

 

转载地址:http://kyjbo.baihongyu.com/

你可能感兴趣的文章
(笔记 - 纯手敲)Spring的IOC和AOP 含GIT地址
查看>>
7-设计模式介绍
查看>>
让运维更高效:关于ECS系统事件
查看>>
J2EE分布式框架--单点登录集成方案
查看>>
跨域传递参数
查看>>
android 4.2的新特性layoutRtl,让布局自动从右往左显示
查看>>
iOS tableView 下拉列表的设计
查看>>
sharepoint 2010 属性编辑工具 SPCamlEditor 1.5.1
查看>>
JAVA学习笔记--4.多线程编程 part3.JAVA多线程的常见概念和基本类库
查看>>
linux下配置网络环境
查看>>
java Windows7 下环境变量设置
查看>>
NBU异构还原Oracle完整备份的一些总结
查看>>
freeBSD安装详细讲解
查看>>
WSFC2016 VM弹性与存储容错
查看>>
文档管理,文本编辑控件TX Text Control .NET for WPF
查看>>
复习 Python 匿名函数 内建函数
查看>>
Security Identifiers | Win SRV2016 SID Change 修改
查看>>
看看来自日本的扫描,做网站需要注意的
查看>>
JDK 1.7+Android SDK+IntelliJ IDEA 13+Genymotion 安卓开发环境部署
查看>>
钓鱼邮件***防范指南
查看>>