摘要: inline int qmod(int& x) { return x < mod ? x : x -= mod; } template<const int mod = 998244353> struct FWT{ const int inv2 = ksm(2, mod - 2); int l; vo 阅读全文
posted @ 2021-08-04 18:57 wlhp 阅读(69) 评论(0) 推荐(0)
摘要: https://vjudge.net/problem/%E9%BB%91%E6%9A%97%E7%88%86%E7%82%B8-4589 FWT模板题 struct FWT{ const int inv2 = ksm(2, mod - 2); int l; void init(int n) { l 阅读全文
posted @ 2021-08-04 15:04 wlhp 阅读(32) 评论(0) 推荐(0)
摘要: B:Boxes 概率签到,根据样例找找规律,显然的结论的min(sum, c + x) 减去x后发现好像是 \(\sum_{i=1}^{n-1} \frac {x_i} {2^i}\) 这个样子的,猜猜结论最小的期望,那么不就是先拿花费小的,搞个前缀和好像和样例对的上 有人害我!!! void ru 阅读全文
posted @ 2021-07-31 22:04 wlhp 阅读(9) 评论(0) 推荐(0)
摘要: 解法有wqs二分和反悔贪心 反悔贪心一般的形式就是通过一个优先队列来贪心 做法很巧妙,优先队列维护最大值,当你拿了 \(a_i\),显然只可能 \(a_{i-1} + a_{i + 1} > a_i\),那么可以把 $a_{i-1}+a_{i+1}-a_i$看作一个整体再放进去 int a[maxn 阅读全文
posted @ 2021-07-30 20:47 wlhp 阅读(15) 评论(0) 推荐(0)
摘要: 1004: Display Substring 二分+后缀自动机 后缀自动机的每个节点有$a[i].len-a[a[i].fa].len$个字符串,且是连续的后缀如$acbc、cbc、bc$,所以对于每个节点 它的权值根据字符串由长到短是递减的,所以我们可以二分答案,再对每个节点利用前缀和二分判断这 阅读全文
posted @ 2021-07-29 18:19 wlhp 阅读(40) 评论(0) 推荐(0)
摘要: https://www.luogu.com.cn/problem/P4173 给你 \(a, b\) 串,\(|a| = n, |b| = m\), 求 \(a\) 中与 \(b\) 匹配的串个数以及下标 当不存在通配符时,就是求 $\sum_{\sum_{i = 0}{ m - 1} a(x - 阅读全文
posted @ 2021-07-28 22:21 wlhp 阅读(9) 评论(0) 推荐(0)
摘要: 1003:Forgiving Matching https://codeforces.com/problemset/problem/528/D 这道题和这个差不多 \(a, b\) 串,\(|a| = n, |b| = m\), 求 \(a\) 的所有长为 \(m\) 的子串有多少位置与 \(b\) 阅读全文
posted @ 2021-07-27 22:46 wlhp 阅读(17) 评论(0) 推荐(0)
摘要: E: J: 显然可以分成两部分求解,二分答案,所有数减去mid后维护前缀和,若存在大于x的区间大于0,就是ok的 这题的本质其实是wqs二分,也就是对每个值减去mid,求最大avg 然后如果 \(x\) 在 \(l(c), r(c)\) 是中,那么解就有了。 double a[maxn], b[ma 阅读全文
posted @ 2021-07-26 21:03 wlhp 阅读(6) 评论(0) 推荐(0)
摘要: B :Black and white 非常巧妙的题目,转化成最小生成树,相当于对一个格子(x, y),将它染黑就是对$x_i, y_j$连了一条边,要保证图的连通性 还有桶排序的kruskcal vector<pair<int, int>> v[100001]; int fa[10001]; inl 阅读全文
posted @ 2021-07-25 19:55 wlhp 阅读(9) 评论(0) 推荐(0)
摘要: 1008:简单dp struct node{ int sco, day; node(int x = 0, int y = 0) { sco = x; day = y; } }a[55][15005]; int p[55]; char s[200]; int dp1[55][102], dp2[505 阅读全文
posted @ 2021-07-22 19:19 wlhp 阅读(23) 评论(0) 推荐(0)