上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 56 下一页
摘要: 是一个单调队列优化dp的典型例子。f[i]=min(f[j])+1,从[i-k,i-1]中转移过来,维护单调递增的队列,每次取队首元素+1就好了。转移分两种情况,[0,i]或者[i-k,i]这个区间里全是01交替的,那么你只能选f[i-1]也就是最大的,取队尾元素就可以了;否则取队首。 #inclu 阅读全文
posted @ 2020-03-11 21:33 WeiAR 阅读(101) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <cstdio> #include <queue> #include <algorithm> #include <cmath> #include <cstring> #define inf 2147483647 #define N 10000 阅读全文
posted @ 2020-03-11 15:40 WeiAR 阅读(152) 评论(0) 推荐(0) 编辑
摘要: http://47.95.147.191/problem/R2D2-Amanacher模板题,当时没写出来真的是 #include <iostream> #include <cstdio> #include <queue> #include <algorithm> #include <cmath> 阅读全文
posted @ 2020-03-09 16:20 WeiAR 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 倒水问题,dfs暴力23333 1 #include <iostream> 2 #include <cstdio> 3 #include <queue> 4 #include <algorithm> 5 #include <stack> 6 #include <cstring> 7 #define 阅读全文
posted @ 2020-02-27 15:03 WeiAR 阅读(305) 评论(0) 推荐(0) 编辑
摘要: http://47.95.147.191/contest/6/problem/A这个题气其实是比较巧妙的。如果选了第3个,就不能选2,4。假设3是最大的,如果选2必选4,选2了却不选4那么不如选3.如果最优解是选2,4,但是贪心的时候选了3,怎么弥补呢?把a[3]=a[2]+a[4]-a[3]再放到 阅读全文
posted @ 2020-02-26 20:08 WeiAR 阅读(193) 评论(0) 推荐(0) 编辑
摘要: http://47.95.147.191/problem/P3规定边数的最短路,跑floyd+矩阵快速幂 #include<iostream> #include<cstdio> #include<queue> #include<algorithm> #include<cmath> #include< 阅读全文
posted @ 2020-02-26 17:36 WeiAR 阅读(143) 评论(0) 推荐(0) 编辑
摘要: http://47.95.147.191/contest/4/problem/Af[i][j]表示已经完成j道且最后一个月完成[i,j]题目的最少月数。 #include <iostream> #include <cstdio> #include <queue> #include <algorith 阅读全文
posted @ 2020-02-25 22:15 WeiAR 阅读(192) 评论(0) 推荐(0) 编辑
摘要: CodeForces - 626D 前缀和+概率cnt[i]表示差为i的数对的数量;sum[]为cnt的前缀和i表示第一回合的差,j表示第二回合的差,i+j小于第3回合,第三回合一共sum[5000]-sun[i+j],最后用组合公式算一下 #include <iostream> #include 阅读全文
posted @ 2020-02-23 22:47 WeiAR 阅读(132) 评论(0) 推荐(0) 编辑
摘要: CodeForces - 566D t[i]表示与i不是一个祖先的最近的一个位置,合并[l,r]的时候就可以跳着合并 #include <iostream> #include <cstdio> #include <queue> #include <algorithm> #include <cmath 阅读全文
posted @ 2020-02-23 22:24 WeiAR 阅读(183) 评论(0) 推荐(0) 编辑
摘要: CodeForces - 919E i的周期是p,a^i的周期是p-1,枚举i,求a^i的逆元,i=c=b*a^(-i),每当右边指数增加p-1(实际大小不变),左边都会减少1,所以差了i-c个p-1周期,所以第一个满足条件的周期就找到了。因为p是质数,求逆元用费马小定理。复杂度是p*logp #i 阅读全文
posted @ 2020-02-23 17:57 WeiAR 阅读(108) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 56 下一页