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,…
P2944 [USACO09MAR]地震损失2Earthquake Damage 2 $P$个点,$C$条双向边.求最少删去几个点使$N$个给定的点与点$1$分开. 显然的最小割. 将点$i$套路地拆成$i_1,i_2$,割点转化成割边 对于点$1$:$link(S,1_1,inf),link(1_1,1_2,inf)$.保证不被割掉,且分到$S$割中 对于每个给定点$k$:$link(k_2,T,inf),link(k_1,k_2,inf)$.保证不被割掉,且分到$T$割中 对于每条双向边$(…
地震破坏 时间限制: 1 Sec  内存限制: 128 MB 题目描述 威斯康星发生了一场地震!约翰的牧场遭到了打击,有一些牛棚变成了废墟,如果一间牛棚遭到 了破坏,那么所有和它相连的道路都不能使用了. 约翰有 N 个牛棚,编号为 1 到 N,有 M 条双向道路连接这些牛棚,第 i 条道路连接的牛棚是 A i 和 B i ,A i 可能等于 B i ,也可能有多条道路连接同一对牛棚. 约翰让奶牛们集中到 1 号牛棚避难.有 P 头奶牛通过手机向约翰求救,她们的遭遇类似:好消 息是她们所在的牛棚没…
传送门 分析 我们让s到1,关键点到t分别连流量为inf的边 于是我们可以考虑跑s到t的最小割 于是我们将所有点拆为两个点,关键点和1的两个点之间连inf,其余点连1 将原图的边也连上,流量为inf 于是跑最小割即可 代码 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cctype>…
P2947 [USACO09MAR]仰望Look Up 74通过 122提交 题目提供者洛谷OnlineJudge 标签USACO2009云端 难度普及/提高- 时空限制1s / 128MB 提交  讨论  题解 最新讨论更多讨论 中文翻译应当为向右看齐 题目中文版范围.. 题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Co…
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…
P1343 地震逃生 题目描述 汶川地震发生时,四川XX中学正在上课,一看地震发生,老师们立刻带领x名学生逃跑,整个学校可以抽象地看成一个有向图,图中有n个点,m条边.1号点为教室,n号点为安全地带,每条边都只能容纳一定量的学生,超过楼就要倒塌,由于人数太多,校长决定让同学们分成几批逃生,只有第一批学生全部逃生完毕后,第二批学生才能从1号点出发逃生,现在请你帮校长算算,每批最多能运出多少个学生,x名学生分几批才能运完. 输入输出格式 输入格式: 第一行3个整数n,m,x(\(x<2^{31},n…
题目传送门 大概思路就是把这两个数组排序.在扫描一次,判断大小,累加ans. #include<bits/stdc++.h> using namespace std; int x,y,z; ],m[]; long long s; int main(){ cin>>z>>x>>y; ;i<=z;i++) cin>>n[i]>>m[i]; sort(n+,n++z); sort(m+,m++z); ;i<=z;i++){ if…
题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height H_i (1 <= H_i <= 1,000,000). Each cow is looking to her left toward those with higher index numbers. We say that cow…
传送门 题目大意: ai,ai+1,ai+2... 变成 bi,bi+1,bi+2.. 不计顺序,增加和减少a数组均有代价. 题解:贪心+排序 小的对应小的 代码: #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #define N 25009 #define LL long long using namespace std; int n,x,y; LL an…