原网站大概已经上不了了-- 题目大意: 求出平面上n个点组成的一个包含顶点数最多的凸多边形.n<=250. 考虑我们每次枚举凸包的左下角为谁(参考Graham求凸包时的左下角),然后像Graham一样,将其他点相对于当前左下角做一个极角排序. 我们会想到一个dp,dp[i][j]表示当前边为i到j的最多点,得到下面这样的转移: for (int i=1;i<=n;i++) if (x!=i) dp[x][i]=1; for (int i=1;i<=n;i++) for (int j=i+…
[题解] 要求出树上两点间的距离,树上的边有边权,本来应该是个LCA. 看他数据小,Xjb水过去了...其实也算是LCA吧,一个O(n)的LCA... #include<cstdio> #include<algorithm> #define N (1010) #define rg register #define LL long long using namespace std; int n,m,root,cnt,tot,dep[N],in[N],out[N],fa[N],last…
-------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<iostream> #include<cstring> #define rep( i , n ) for( int i = 0 ; i < n ; ++i ) #define clr( x , c ) memset( x…
Hay For Sale 购买干草 bzoj-1606 Usaco-2008 Dec 题目大意:约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤50000)个单位的马车,去顿因家买一些干草. 顿因有H(1≤H≤5000)包干草,每一包都有它的体积Vi(l≤Vi≤C).约翰只能整包购买,他最多可以运回多少体积的干草呢? 想法:傻逼背包裸题,直接01背包即可. 最后,附上丑陋的代码... ... #include <iostream> #include &…
无限背包dp.. 因为题目中说至少到 H 磅 , 我就直接把 H * 2 了.. -------------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #define rep( i , n ) for( int i = 0 ; i…
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1606 价值和重量相等的01背包问题. 分析 ... #include <bits/stdc++.h> using namespace std; +,maxn=+; int n,W; int w[maxn],dp[maxw]; int main(){ scanf("%d%d",&W,&n); ;i<=n;i++) scanf("%d&quo…
[BZOJ 1652][USACO 06FEB]Treats for the Cows Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given…
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…
NC24083 [USACO 2017 Dec P]Greedy Gift Takers 题目 题目描述 Farmer John's nemesis, Farmer Nhoj, has N cows (\(1≤N≤10^5\)), conveniently numbered 1-N. They have unexpectedly turned up at Farmer John's farm, so the unfailingly polite Farmer John is attempting…
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…
题面:P2925 [USACO08DEC]干草出售Hay For Sale 题解:无 代码: #include<cstdio> #include<cstring> #include<iostream> using namespace std; ,maxh=; int C,H,V[maxh]; bool F[maxc]; int main(){ scanf("%d%d",&C,&H); ;i<=H;i++)scanf("…