摘要: [kuangbin专题] Manacher 实现参考了https://oi-wiki.org/string/manacher/。 POJ 3974 Palindrome 求字符串$A$的最长回文子串模板题,首先在$A$的第一个字符的左面和$A$的每个字符的后面填充不在输入范围内的字符$,得到串$S$ 阅读全文
posted @ 2019-11-14 14:57 ToRapture 阅读(112) 评论(0) 推荐(0) 编辑
摘要: https://hihocoder.com/problemset/problem/1093 实现参考了算法导论。 #include <bits/stdc++.h> #define DBG(x) cerr << #x << " = " << x << endl using namespace std; 阅读全文
posted @ 2019-11-05 18:35 ToRapture 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 模板 const int N = 1000000 + 16; struct Hash { const unsigned long long KEY = 137; unsigned long long h[N], p[N]; int len; void init(const int a[], int 阅读全文
posted @ 2019-10-31 14:52 ToRapture 阅读(164) 评论(0) 推荐(0) 编辑
摘要: https://hihocoder.com/contest/offers108/problems A 再买优惠 暴力或二分一下 #include <bits/stdc++.h> #define DBG(x) cerr << #x << " = " << x << endl using namespa 阅读全文
posted @ 2019-10-30 19:55 ToRapture 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 按照查询的边权w排序,离线add和query,注意树剖处理边权时的特殊逻辑。 #include <bits/stdc++.h> #define DBG(x) cerr << #x << " = " << x << endl #define lrrt int L, int R, int rt #def 阅读全文
posted @ 2019-04-26 16:02 ToRapture 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Max answer 与POJ 2796 Feel Good类似,但是这个题有负数,需要特殊处理一下 #include <bits/stdc++.h> #define DBG(x) cerr << #x << " = " << x << endl using namespace std; typed 阅读全文
posted @ 2019-04-24 17:15 ToRapture 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 令$sum_{i, j}\(表示从\)(i, j)\(开始沿着\)(i - 1, j), (i - 2, j) \dots (0, j)$方向的连续的$1$的个数, \[ sum_{i, j} = \begin{cases} 0 & m_{i, j} \ne 1 \\ 1 + sum_{i - 1, 阅读全文
posted @ 2018-08-31 23:14 ToRapture 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 有数组$A[N], 1\le N \le 3 \cdot 105$, $P$次查询,对于每次查询给出$pos$和$k$,求$\sum\limits_{pos + m \cdot k \le N} A[pos + m \cdot k]$。 把所有查询按$k$分组,$k \le \sqrt N$的组$O 阅读全文
posted @ 2017-09-19 17:21 ToRapture 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 简单二维偏序 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #define DBG(x) cerr << #x << " = " << x << endl 阅读全文
posted @ 2017-09-19 17:06 ToRapture 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 有一个$N+1$个结点的树$T$。 现在有$Q$个信息,每条信息为$q:(u,v)$,表示$u$到$v$的路径不通。 问树$T$至少被破坏多少个节点才能达到当前这种局面。 #include <bits/stdc++.h> #define DBG(x) cerr << #x << " = " << x 阅读全文
posted @ 2017-09-19 17:05 ToRapture 阅读(110) 评论(0) 推荐(0) 编辑