http://www.lydsy.com/JudgeOnline/problem.php?id=3479 这个还用说吗.... #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #include <queue> using namespace std…
这个= =最近刷的都是水题啊QAQ 排除掉不可能的边然后就最小生成树就行了= = CODE: #include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;#define maxn 2010struct edges{ int x,y,c;}edge[maxn*maxn];int l,x[maxn],y[maxn],n,c,ans,sum,f[…
http://www.lydsy.com/JudgeOnline/problem.php?id=3433 想了好久啊....... 想不出dp啊......sad 后来看到一英文题解.......... sad. 末端点排序...然后对于两个录像机有有两种情况 RECODER1(当前录制节目的区间):----- RECODER1(当前录制节目的区间):----------- 因右端点排序,所以下一个区间大概是:------------------- 可以看出,此时显然不能转移 当这个区间的左端点…
http://www.lydsy.com/JudgeOnline/problem.php?id=3399 贪心就是将两组排序,然后直接模拟即可.. 如果我们用a去匹配一个绝对值和它差不多的值,那么去匹配的那个位置显然要和它这个位置匹配,同样的高度差... 自己理解吧.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream&g…
MST...一开始没注意-1结果就WA了... ---------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<algorithm> #include<iostream>   #define r…
3479: [Usaco2014 Mar]Watering the Fields Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 174  Solved: 97[Submit][Status][Discuss] Description Due to a lack of rain, Farmer John wants to build an irrigation system to send water between his N fields (1…
[算法]贪心+线段树 [题意]给定n个数字ci,m个区间[a,b](1<=a,b<=10^5),每个位置最多被ci个区间覆盖,求最多选择多少区间. 附加退化问题:全部ci=1,即求最多的不相交的区间. [题解]本题是区间和点之间的经典贪心,有两种经典做法,本质思想都是通过排序实现扫描线,细节根据题目不同而不同. 一.从区间角度出发,按区间右端点从小到大排序 然后再按左端点从大到小排序,从左到右能加就加. 感性理解:在对右影响一致的情况下,选择对左影响最小的. 证明:假设有最优决策序列S和当前决…
这题算是01分数规划吧2333 sum-a[i]*x[i]=c*(n-x[i]) 化简一下就是sum-(a[i]-c)*x[i]-nc=0,每次找最大的(a[i]-c)*x[i](子段和),如果结果<=0就是存在方案使sum-a[i]*x[i]=c*(n-x[i]). 注意要至少选一个…… #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #define max…
http://www.lydsy.com/JudgeOnline/problem.php?id=3432 题目说要相互可达,但是只需要从某个点做bfs然后判断其它点是否可达即可. 原因太简单了.....因为它是abs 所以我们二分D,然后判断即可 #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include…
http://www.lydsy.com/JudgeOnline/problem.php?id=3401 还能更裸一些吗.. 维护一个递减的单调栈 #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #include <queue> using nam…