I and OI
Past...
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 35 下一页
摘要: 题意:最多去掉一个树上的s条边,将树分割成S+1块,使得所有块的最长链的最大值最小.USACO官方的题解讲的很清楚..First, conduct a binary search on the answer, D. To do this, just find a way to check, for any D, if it is possible to make S cuts such that each tree has diameter at most D.We will give a greedy algorithm which will compute the smallest num 阅读全文
posted @ 2011-08-14 15:44 exponent 阅读(354) 评论(0) 推荐(0) 编辑
摘要: 简单的最短路.要用堆优化的dijkstra.当复习了.code:/************************************************************** Problem: 2100 User: exponent Language: Pascal Result: Accepted Time:572 ms Memory:7356 kb ****************************************************************/ type edge=record v,w,n:longint; end; const maxm= 阅读全文
posted @ 2011-08-14 13:31 exponent 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 首先O(N^2)的DP挺好想的.f[i,j]=sum[i,j]-min(f[i+1,j],f[i,j-1]).但题目把n出到5000,内存卡到64M,二维的状态存不下..其实,j这一维可以省掉.我们换个状态表示f[i,i+len]=sum[i,i+len]-min(f[i+1,i+len],f[i,i+len-1])然后循环这样写:for len=1 to n for i=1 to n-len.容易看出第二维可以省掉了.code:/************************************************************** Problem: 2101 User: 阅读全文
posted @ 2011-08-14 13:02 exponent 阅读(239) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 35 下一页