随笔分类 -  数据结构——单调队列

摘要:题解看 "这里" cpp include include include using namespace std; int t, maxp, w, dp[2005][2005], qaq[2005], haq, taq, ap, bp, as, bs, ans; int main(){ cin t 阅读全文
posted @ 2018-01-18 09:04 poorpool 阅读(126) 评论(0) 推荐(0)
摘要:和「理想的正方形」比较相似,需要先掌握那道题。 花坛外头每一边必须套上绿化带 cpp include include using namespace std; int n, m, a, b, c, d, qwq[1005], twq, hwq, zzxz[1005][1005], ans; int 阅读全文
posted @ 2018-01-17 19:36 poorpool 阅读(187) 评论(0) 推荐(0)
摘要:先对于每一行中长度为 n 的列用单调队列搞出它们的最小/大值,再将这些长度为 n 的列想象成点再对行跑一遍 cpp include include include using namespace std; int a, b, n, r[1005][1005], qwq[1005], qaq[1005 阅读全文
posted @ 2018-01-17 16:36 poorpool 阅读(113) 评论(0) 推荐(0)
摘要:排序枚举左端点,则右端点必定不降 cpp include include include include using namespace std; struct Node{ int pos, val; }nd[1000005]; int n, k, cnt[63], uu, vv=0, rig=0, 阅读全文
posted @ 2018-01-04 08:45 poorpool 阅读(131) 评论(0) 推荐(0)
摘要:单调队列+二分答案 cpp include include include include using namespace std; struct Node{ int x, y; }nd[100005]; int n, d, ans, q1[100005], q2[100005], l1, r1, 阅读全文
posted @ 2018-01-02 22:03 poorpool 阅读(163) 评论(0) 推荐(0)
摘要:设dp[i]表示i位置不选且i之前的都合法的最小损失值。 cpp include include include using namespace std; typedef long long ll; //dp[i] = min{dp[j]} + w[i] | i j i k 1 n k; for(i 阅读全文
posted @ 2017-12-01 11:15 poorpool 阅读(108) 评论(0) 推荐(0)
摘要:单调队列 cpp include include using namespace std; int n, l, r, dp[400005], a[200005], q[200005], hea, tai; //dp[i] = max{dp[k]} + w[i] | i r n l r; for(in 阅读全文
posted @ 2017-11-30 20:44 poorpool 阅读(113) 评论(0) 推荐(0)
摘要:单调队列优化dp cpp include include using namespace std; int dp[1000005], n, m, q[1000005], l, r, w[1000005]; //dp[i] = dp[j] + w[i] | i m n m; for(int i=1; 阅读全文
posted @ 2017-11-30 20:06 poorpool 阅读(404) 评论(0) 推荐(0)
摘要:模板题 cpp include include include using namespace std; int l1=1, r1, l2=1, r2, q1[1000005], q2[1000005], a[1000005], n, k; int ans1[1000005], ans2[10000 阅读全文
posted @ 2017-11-30 19:38 poorpool 阅读(120) 评论(0) 推荐(0)