题目描述 输入 * 第1行: 两个由空格隔开的整数: N和V * 第2到第N+1行: 第i+1行表示第i种游戏平台的价格和可以在这种游戏平台上面运行的游 戏.包含: P_i, G_i还有G_i对由空格隔开的整数GP_j, PV_j 输出 * 第1行: 农夫约翰在预算内可以得到的最大的产出值. 样例输入 3 800 300 2 30 50 25 80 600 1 50 130 400 3 40 70 30 40 35 60 样例输出 210   一看到这题第一感觉就是背包,这题确实就是背包,只不过…
题目描述 跟所有人一样,农夫约翰以着宁教我负天下牛,休叫天下牛负我的伟大精神,日日夜夜苦思生 财之道.为了发财,他设置了一系列的规章制度,使得任何一只奶牛在农场中的道路行走,都 要向农夫约翰上交过路费. 农场中由N(1 <= N <= 250)片草地(标号为1到N),并且有M(1 <= M <= 10000)条 双向道路连接草地A_j和B_j(1 <= A_j <= N; 1 <= B_j <= N).奶牛们从任意一片草 地出发可以抵达任意一片的草地.FJ已…
Link: USACO 2017 Dec Gold 传送门 A: 为了保证复杂度明显是从终结点往回退 结果一开始全在想优化建边$dfs$……其实可以不用建边直接$multiset$找可行边跑$bfs$就行了 由于保证每个点只进队列一次.被搜索到一次,因此复杂度为$O(n*log(n))$ #include <bits/stdc++.h> using namespace std; #define X first #define Y second typedef long long ll; typ…
NC24866 [USACO 2009 Dec S]Music Notes 题目 题目描述 FJ is going to teach his cows how to play a song. The song consists of N (1 <= N <= 50,000) notes, and the i-th note lasts for Bi (1 <= Bi <= 10,000) beats (thus no song is longer than 500,000,000…
权限题,不给传送门啦!在学校OJ上交的.. 有些不开心,又是一道贪心,又是一个高级数据结构的模板,又是看了别人的题解还写崩了QAQ,蒟蒻不需要理由呀. 正经题解: 首先,我们可以由「显然成立法」得出,只要我们按照右端点排序,然后能塞多少就塞多少就一定是最优哒! 你们可以YY一下,如果一堆牛能下车就赶紧下是不是可以得出最优的呢,我感觉不对但是他们都说对 然后就是很基本的线段树维护区间的查询和修改了. 需要注意的一个小地方是如果是线段树修改区间右端点是要-1的,这个很显然. 下面是具体实现: //O…
/*codevs 3279 二分+dfs贪心检验 堆版本 re一个 爆栈了*/ #include<cstdio> #include<queue> #include<cstring> #define pa pair<int,int> #define mk make_pair #define X first #define Y second #define maxn 100010 using namespace std; int n,S,num,head[max…
标题效果:一个N积分m无向图边.它可以是路径k右边缘值变0,确定此时1-n最短路径长度. Sol:我以为我们考虑分层图,图复制k+1部分,每间0~k一层.代表在这个时候已经过去"自由边缘"文章编号. 层与层之间的边权值为0且为单向由上层指向下层. 这样我们以0层的1点做单源最短路径.每一层的n点的距离最小值即为答案. 仅仅只是这种点数为O(K*N),边数为O(K*M),比較慢. 我的做法是,对每一层使用heap-dijkstra算法由本层的原点更新这一层的最短路长度.然后显然能够用O(…
Link: 传送门 A: 贪心从小到大插入,用并查集维护连通性 #include <bits/stdc++.h> using namespace std; #define X first #define Y second typedef double db; typedef long long ll; typedef pair<int,int> P; ; int n,tot,cnt,f[MAXN];P dat[MAXN]; struct edge{int x,y;ll w;}e[M…
Problem 3: Threatening Letter [J. Kuipers, 2002] FJ has had a terrible fight with his neighbor and wants to send him a nasty letter, but wants to remain anonymous. As so many before him have done, he plans to cut out printed letters and paste them on…
Problem 1: Cow Calisthenics [Michael Cohen, 2010] Farmer John continues his never-ending quest to keep the cows fit by having them exercise on various cow paths that run through the pastures. These cow paths can be represented as a set of vertices co…