UVa 753 - A Plug for UNIX(最大流)】的更多相关文章

题意:给定 n 种插座,m种设备,和k个转换器,问你最少有几台设备不能匹配. 析:一个很裸的网络流,直接上模板就行,建立一个源点s和汇点t,源点和每个设备连一条边,每个插座和汇点连一条边,然后再连转换器, 最后跑一次最大流即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib…
链接 : http://acm.hust.edu.cn/vjudge/problem/viewProblem.action? id=26746 题目意思有点儿难描写叙述 用一个别人描写叙述好的. 我的建图方法:一个源点一个汇点,和全部种类的插座.输入的n个插座直接与源点相连,容量为1,m个物品输入里 记录每一个插座相应的物品个数.物品数然后大于0的插座直接连到汇点.意味着终于的物品仅仅能由这些插座流出.中间的插座转换容量都是INF  a b表示  不管多少b都能够选择转化到a. /*------…
POJ 1087 A Plug for UNIX / HDU 1526 A Plug for UNIX / ZOJ 1157 A Plug for UNIX / UVA 753 A Plug for UNIX / UVAlive 5418 A Plug for UNIX / SCU 1671 A Plug for UNIX (网络流) Description You are in charge of setting up the press room for the inaugural meet…
  A Plug for UNIX  You are in charge of setting up the press room for the inaugural meeting of the United Nations Internet eXecutive (UNIX), which has an international mandate to make the free flow of information and ideas on the Internet as cumberso…
A Plug for UNIX You are in charge of setting up the press room for the inaugural meeting of the United Nations Internet eXecutive (UNIX), which has an international mandate to make the free flow of information and ideas on the Internet as cumbersome…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=694 题意: 有n个插座,m个设备和k(n,m,k≤100)种转换器,每种转换器都有无限多.已知每个插座的类型,每个设备的插头类型,以及每种转换器的插座类型和插头类型.插头和插座类型都用不超过24个字母表示,插头只能插到类型名称相同的插座中.例如,有4个插座,类型分别为A, B, C…
关键在建图,转换器连一条容量无限的边表示可以转化无数次,设备的插头连源点,插座连汇点. dinic手敲已熟练,输出格式又被坑,总结一下,输出空行多case的,一个换行是必要的,最后一个不加空行,有Testcase最后一个不要换行,没有testcase最后一个要加换行,想起那天gold miner PE了两发. 对dinic网络流的简单理解:bfs找有没有增广路,dfs增广. 关键的概念:反向边,给一个反悔的机会. #include<bits/stdc++.h> using namespace…
题意: 给n个插座,m个设备(肯定要插电了),k种转换头可无限次使用(注意是单向的),问有多少设备最终是不能够插上插座的? 分析: 看起来就是设备匹配插座,所以答案不超过m.这个题适合用网络流来解. 假设每种头对应着一个编号(可以用map实现转换string到int),主要在k种转换头的建边,他们之间的转换关系就是编号与编号之间的边,因为可以无限次使用,所以容量无穷.再添加源点和汇点就建完了,汇点连接每个插座,源点连接每个设备,每边容量为1.使用增广路算法就得出解了.注意要空一行. 很不愿意用结…
最大流解决 . 设置源点 0,连接所有设备(device) .设备-插头 -汇点 #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include &l…
题意 给定一些插头设备和插座,有一些方法可以把其中一些插头变成另一种插头.求无法匹配插座的插头设备个数. 题解 用\(map\)给每个字符串标号为\(a_i\)和\(b_i\). 读入每种改变插头的方法,连边,权值为\(inf\). 然后连边\(S \longrightarrow a_i\),权值为\(1\):\(b_i \longrightarrow T\),权值为\(1\). 跑最大流即可. 代码 #include <bits/stdc++.h> #define FOPI freopen(…