题目大意:有n个点m条单向边,每条边有一个容量.现有x人要分批从1走到n,问每批最多能走多少人,分几批运完(或输出无法运完). 解题思路:一看就是网络流的题目.每批最多能走多少人,即最大流.分几批运完,除一下即可.当最大流为0时无法运完. 以下是Dinic算法的代码(为什么我那么喜欢用Dinic?因为我个人认为它好写!): C++ Code: #include<cstdio> #include<queue> #include<cstring> using namespa…
洛谷4951 地震 #include<iostream> #include<cstdio> #include<algorithm> #define go(i,a,b) for(register int i=a;i<=b;i++) #define ll long long #define db long double #define M 10001 #define N 401 #define inf 1e15 #define eps 1e-12 using name…
P1948 [USACO08JAN]电话线Telephone Lines 题目描述 Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to the phone system. There a…
挺神奇 题目描述 动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形.A 吃 B,B 吃 C,C 吃 A. 现有 N 个动物,以 1 - N 编号.每个动物都是 A,B,C 中的一种,但是我们并不知道 它到底是哪一种. 有人用两种说法对这 N 个动物所构成的食物链关系进行描述: 第一种说法是“1 X Y”,表示 X 和 Y 是同类. 第二种说法是“2 X Y”,表示 X 吃 Y . 此人对 N 个动物,用上述两种说法,一句接一句地说出 K 句话,这 K 句话有的是真 的,有的是…