题目大概是说,一个村庄有n间房子,房子间有m条双向路相连.1号房子有网络,有k间房子要通过与1号房子相连联网,且一条路上不能有同样颜色的线缆,问最少要用几种颜色的线缆. 二分枚举颜色个数,建立容量网络跑最大流判断解是否成立:源点是1,所有要联网的房子向汇点连容量1的边,所有双向边改为容量为枚举的解的边,如果最大流等于k那这个解就成立. 注意重边.. #include<cstdio> #include<cstring> #include<queue> #include&l…
NETADMIN - Smart Network Administrator #max-flow The citizens of a small village are tired of being the only inhabitants around without a connection to the Internet. After nominating the future network administrator, his house was connected to the gl…
The citizens of a small village are tired of being the only inhabitants around without a connection to the Internet. After nominating the future network administrator, his house was connected to the global network. All users that want to have access…
The citizens of a small village are tired of being the only inhabitants around without a connection to the Internet. After nominating the future network administrator, his house was connected to the global network. All users that want to have access…
在spoj上用题号找题就已经是手动二分了吧 把1作为汇点,k个要入网的向t连流量为1的边,因为最小颜色数等于最大边流量,所以对于题目所给出的边(u,v),连接(u,v,c),二分一个流量c,根据最大流是否等于k来调整上下界. #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; const int N=505,inf=1e9; in…
传送门[洛谷] 常见套路? 关键点连新建汇点 流量1 源点1 原图中的边 二分流量. 二分+判满流 做完了. 附代码. #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<queue> #define inf 20021225 #define ll long long #define mxm 251000 #define mxn 510 u…
题目大意:一座村庄有N户人家.只有第一家可以连上互联网,其他人家要想上网必须拉一根缆线通过若干条街道连到第一家.每一根完整的缆线只能有一种颜色.网管有一个要求,各条街道内不同人家的缆线必须不同色,且总的不同颜色种数最小.求在指定的K户人家都能上网的前提下,最小的不同颜色种数.(1 <= N <= 500) 题解:上来看到颜色就不知道怎么下手了...那么我们不妨就枚举颜色好了:先按照题意建模,再对于每一个街道限一下我们枚举的颜色就好了,如果最大流小了说明不行,如果正好等于k就说明可以.那么不难看…
https://en.wikipedia.org/wiki/Border_Gateway_Protocol Border Gateway Protocol (BGP) is a standardized exterior gateway protocol designed to exchange routing and reachability information among autonomous systems (AS) on the Internet.[1] The protocol i…
Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 20754   Accepted: 10872 Description A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount…
Power Network Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 25108   Accepted: 13077 Description A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied…