![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
贪心
文章平均质量分 77
TheWolfWhistlingSong
蜜の夜明け
展开
-
Bzoj1113:[Poi2008]海报PLA:贪心+单调栈
题目链接:1113:[Poi2008]海报PLA 发现只要有一个向上凸起的矩形,就会ans++ 所以用一发单调栈维护高度值,宽度并没有什么卵用 #include #include #include #include using namespace std; const int maxn=1000010; int n,m,sta[maxn],a[maxn],ans=0; int main(){原创 2016-04-08 10:32:27 · 356 阅读 · 0 评论 -
Bzoj4069:[Apio2015]巴厘岛的雕塑:dp+贪心
题目链接:[Apio2015]巴厘岛的雕塑 一开始先写了个既错误又高复杂度的dp,令dp[i][j]=min(dp[i][k],dp[j][k-1]|(s[i]-s[j])),其中s[]代表前缀和 首先超时不说,在或的情况下单纯地每步取最小值无法保证全局的最优性,但是即使是这样我还是奇奇怪怪的过了好几个点QAQ 正解是这样的: 首先处理出答案最多的可能位数bit,然后倒序从最高位开始枚举每原创 2016-04-25 17:17:18 · 831 阅读 · 0 评论 -
Bzoj3790:神奇项链:manacher+线段树+贪心
题目链接:3790:神奇项链 处理出每个位置的最长的回文串,然后就是用最少的回文串覆盖整个区间 贪心一下,线段树维护即可,每次在左端点在合法区间里的回文串中找右端点最远的即可 #include #include #include #include #include using namespace std; const int maxn=210000; const int inf=0x7fff原创 2016-07-14 15:52:38 · 404 阅读 · 0 评论