上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 120 下一页
摘要: 思路自然的码农题. 显然分类讨论一下编号在 $[l,r]$ 的点与 $p$ 的子树关系. 如果都在 $p$ 的子树内就是个区间 $lca$. 否则,就二分第一个满足 $p$ 的祖先且子树内部没有 $[l,r]$ 之间的点. 二分验证的话要用主席树. code: #include <cstring> 阅读全文
posted @ 2020-02-13 15:42 EM-LGH 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 题意:令 $f(i)$ 表示对于 $\binom{n}{i}$ 种包含 $i$ 个点的最小连通块的总节点个数和. 面对个数和/价值和且点和点之间没有限制条件的问题时可以考虑单独处理每个点的贡献. 考虑点 $j$ 对 $f(i)$ 的贡献. 那么 $j$ 对 $f(i)$ 有贡献时分两种情况. 1. 阅读全文
posted @ 2020-02-13 10:51 EM-LGH 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 将问题转化为统计以 $i$ 结尾的 $AA$ 串个数. 我们将后缀树建出来,然后按照启发式合并的方式每次合并两个 $endpos$ 集合. 那么就有:$[x-mx,x-1] \rightarrow x$ 与 $x \rightarrow [x+1,x+mx]$ 的贡献. 统计第一种贡献的话在线段树上 阅读全文
posted @ 2020-02-12 16:58 EM-LGH 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 我们发现我们可以直接让 $x_{i}=i$,然后模拟就行了. code: #include <cstdio> #include <cstring> #include <cmath> #include <vector> #include <map> #include <algorithm> #defi 阅读全文
posted @ 2020-02-11 15:57 EM-LGH 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 用 trie 搜索一下就好了. code: #include <bits/stdc++.h> #define N 10008 #define setIO(s) freopen(s".in","r",stdin) using namespace std; char S[24]; int trie[N* 阅读全文
posted @ 2020-02-11 11:07 EM-LGH 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 滚动数组推一下就行. code: #include <bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) using namespace std; int dp[2][4][4][4][4],n; char s[100004]; int 阅读全文
posted @ 2020-02-11 10:24 EM-LGH 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 这种多线程问题可以采用一维枚举,另一位用 dp 求解最优解来实现. 这道题和那个 ZJOI 的食堂排队的题挺像的. code: #include <bits/stdc++.h> #define ll long long #define inf 0x3f3f3f3f #define N 508000 阅读全文
posted @ 2020-02-11 10:06 EM-LGH 阅读(102) 评论(0) 推荐(0) 编辑
摘要: code: #include <cstdio> #include <cstring> #include <algorithm> #define ll long long #define MAXN 160 #define MAXK 20 #define mod 12345678 #define set 阅读全文
posted @ 2020-02-10 21:35 EM-LGH 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 第一次写这个题是好长时间以前了,然后没调出来. 本来以为是思路错了,结果今天看题解发现思路没错,但是好多代码细节需要注意. code: #include <cstdio> #include <vector> #include <map> #include <cstring> #include <al 阅读全文
posted @ 2020-02-09 15:27 EM-LGH 阅读(169) 评论(0) 推荐(0) 编辑
摘要: A - Sasha and a Bit of Relax code: #include <cstdio> #include <map> #include <cstring> #include <algorithm> #define N 300006 #define ll long long #def 阅读全文
posted @ 2020-02-07 21:25 EM-LGH 阅读(150) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 120 下一页