题意 给定 n 个城市,m 条边.人只能从走相邻边相连(只能走一次)的城市. 现在给你初始城市的每一个人数,再给一组每个城市人数.询问是否可以从当前人数变换到给定人数.如果能,输入"YES"并输出方案,不能则输出"NO". http://codeforces.com/contest/546/problem/E 思路 当∑a!=∑b时,肯定不能. 建一个超级源点s和超级汇点t,s到(1~n)连一条容量为a[i]的边,(n+1~2*n)到t连一条容量为b[i]的边,再将…
CF546E Soldier and Traveling 题目描述 In the country there are \(n\) cities and \(m\) bidirectional roads between them. Each city has an army. Army of the i-th city consists of \(a_{i}\) soldiers. Now soldiers roam. After roaming each soldier has to eith…
题目描述 In the country there are n n n cities and m m m bidirectional roads between them. Each city has an army. Army of the i i i -th city consists of ai a_{i} ai​ soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city o…
题目大概说一张无向图,各个结点初始有ai人,现在每个人可以选择停留在原地或者移动到相邻的结点,问能否使各个结点的人数变为bi人. 如此建容量网络: 图上各个结点拆成两点i.i' 源点向i点连容量ai的边 i'向汇点连容量bi的边 i向i'连容量INF的边 对于相邻的两点(u,v),u向v'连容量INF的边,v'向u连容量INF的边 跑最大流看看最大流是否等于∑bi.另外,注意∑ai不等于∑bi的情况. #include<cstdio> #include<cstring> #incl…
题目链接 给出n个城市, 以及初始时每个城市的人数以及目标人数.初始时有些城市是相连的. 每个城市的人只可以待在自己的城市或走到与他相邻的城市, 相邻, 相当于只能走一条路. 如果目标状态不可达, 输出no, 否则输出每个城市的人都是怎么走的, 比如第一个城市有2个人走到了第二个城市, 1个人留在了第一个城市, 那么输出的第一行前两个数就是1, 2. 很明显的网络流, 输出那里写了好久... 首先判断能否可达, 如果初始状态的人数与目标状态不一样, 一定不可达, 其次, 如果建完图跑网络流的结果…
题目链接: http://codeforces.com/problemset/problem/546/E E. Soldier and Traveling time limit per test1 secondmemory limit per test256 megabytes 问题描述 In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of…
B. Soldier and Traveling Time Limit: 1000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d      Java class name: (Any) Submit Status In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the …
Power Network 时间限制: 1 Sec  内存限制: 128 MB 题目描述 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 s(u) >= 0 of power, may produce an amount 0 <= p(u…
题意 网络流最大流模板 思路 EK也不会超时 所以说是一个数据比较水的模板题 但是POJ有点坑,多组数据,而且题目没给 哭得我AC率直掉 代码 用的朴素Dinic #include<cstdio> #include<algorithm> #include<cstring> #include<queue> using namespace std; #define N 200010 #define INF 0x3fffffff inline int read()…
HDU 3081 Marriage Match II (网络流,最大流,二分,并查集) Description Presumably, you all have known the question of stable marriage match. A girl will choose a boy; it is similar as the game of playing house we used to play when we are kids. What a happy time as…