P2932 [USACO09JAN]地震造成的破坏Earthquake Damage 题目描述 Wisconsin has had an earthquake that has struck Farmer John's farm! The earthquake has damaged some of the pastures so that they are unpassable. Remarkably, none of the cowpaths was damaged. As usual, t…
这题怎么这么水~~~本来以为挺难的一道题,结果随便一写就过了...本来还不知道损坏的牛棚算不算,结果不明不白就过了... 题干: 农夫John的农场遭受了一场地震.有一些牛棚遭到了损坏,但幸运地,所有牛棚间的路经都还能使用. FJ的农场有P( <= P <= ,)个牛棚,编号1..P. C( <= C <= ,)条双向路经联接这些牛棚,编号为1..C. 路经i连接牛棚a_i和b_i ( <= a_i<= P; <= b_i <= P).路经可能连接a_i到它…
P2936 [USACO09JAN]全流Total Flow 题目描述 Farmer John always wants his cows to have enough water and thus has made a map of the N (1 <= N <= 700) water pipes on the farm that connect the well to the barn. He was surprised to find a wild mess of different…
https://www.luogu.org/problem/show?pid=2944 题目描述 Wisconsin has had an earthquake that has struck Farmer John's farm! The earthquake has damaged some of the pastures so that they are unpassable. Remarkably, none of the cowpaths was damaged. As usual,…
P2935 [USACO09JAN]最好的地方Best Spot 题目描述 Bessie, always wishing to optimize her life, has realized that she really enjoys visiting F (1 <= F <= P) favorite pastures F_i of the P (1 <= P <= 500; 1 <= F_i <= P) total pastures (conveniently nu…
P1343 地震逃生 题目描述 汶川地震发生时,四川XX中学正在上课,一看地震发生,老师们立刻带领x名学生逃跑,整个学校可以抽象地看成一个有向图,图中有n个点,m条边.1号点为教室,n号点为安全地带,每条边都只能容纳一定量的学生,超过楼就要倒塌,由于人数太多,校长决定让同学们分成几批逃生,只有第一批学生全部逃生完毕后,第二批学生才能从1号点出发逃生,现在请你帮校长算算,每批最多能运出多少个学生,x名学生分几批才能运完. 输入输出格式 输入格式: 第一行3个整数n,m,x(\(x<2^{31},n…
题链: https://www.luogu.org/problemnew/show/P2934 题解: 最短路(树),可并堆(左偏堆),并查集. 个人感觉很好的一个题. 由于题目已经明确说明:从1点到每个点的最短路有且只有一条. 那么跑完最短路后,就可以得到一个最短路树,即每个点只有一个来源点. 然后来考虑,如果某一个u点无法从其最短路树上的father到达时,是个怎样的情况: 由于u无法从其父亲到达,所以如果还存在1到u的路径的话, 应该在其子树内(包括u),存在一个v点,与子树外的某个节点x…
题目描述 Farmer John always wants his cows to have enough water and thus has made a map of the N (1 <= N <= 700) water pipes on the farm that connect the well to the barn. He was surprised to find a wild mess of different size pipes connected in an appa…
一道傻吊的网络流题,wori我写的读入优化怎么老T? 远离读入优化报平安? #include<bits/stdc++.h> #define N 4005 #define inf 1000000007 using namespace std; *N],tot=,n,m,x,s,t,ans; ]; inline void addedge(int u,int v,int f){ G[tot].u=u;G[tot].v=v;G[tot].f=f;G[tot].next=head[u];head[u]=…
题目描述 Bessie, always wishing to optimize her life, has realized that she really enjoys visiting F (1 <= F <= P) favorite pastures F_i of the P (1 <= P <= 500; 1 <= F_i <= P) total pastures (conveniently numbered 1..P) that compose Farmer…