随笔分类 -  其他 - 模型/总结/重要

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 32 下一页
摘要:code: #include <vector> #include <cstdio> #include <cstring> #include <map> #include <set> #include <algorithm> #define N 300005 #define MAX 320005 #d 阅读全文
posted @ 2020-02-15 17:14 EM-LGH 阅读(229) 评论(2) 推荐(0)
摘要:对于点对 $(x,y)$ ,考虑求出其循环节. 那么有 $(x+\frac{x}{B}) \mod A=(x+kB+\frac{x+kB}{B}) \mod A$ 其中 $\frac{x+kB}{B}$ 向下取整显然可以写成 $\frac{x}{B}+k$ 则有 $kB+k=0(\mod A)$ 解 阅读全文
posted @ 2020-02-15 10:16 EM-LGH 阅读(140) 评论(0) 推荐(0)
摘要:A code: #include <cstdio> #include <algorithm> #define N 1000000 #define ll long long #define setIO(s) freopen(s".in","r",stdin) using namespace std; 阅读全文
posted @ 2020-02-14 22:31 EM-LGH 阅读(145) 评论(0) 推荐(0)
摘要:显然从左到右,从上到下依次处理每个格子步数是最少的. 而由于我们的顺序是固定的,每次操作等于是一个区间修改,单点查询. 利用二维差分的方式可以轻松实现. code: #include <cstdio> #include <cstring> #include <string> #include <ve 阅读全文
posted @ 2020-02-13 16:37 EM-LGH 阅读(254) 评论(0) 推荐(0)
摘要:思路自然的码农题. 显然分类讨论一下编号在 $[l,r]$ 的点与 $p$ 的子树关系. 如果都在 $p$ 的子树内就是个区间 $lca$. 否则,就二分第一个满足 $p$ 的祖先且子树内部没有 $[l,r]$ 之间的点. 二分验证的话要用主席树. code: #include <cstring> 阅读全文
posted @ 2020-02-13 15:42 EM-LGH 阅读(158) 评论(0) 推荐(0)
摘要:题意:令 $f(i)$ 表示对于 $\binom{n}{i}$ 种包含 $i$ 个点的最小连通块的总节点个数和. 面对个数和/价值和且点和点之间没有限制条件的问题时可以考虑单独处理每个点的贡献. 考虑点 $j$ 对 $f(i)$ 的贡献. 那么 $j$ 对 $f(i)$ 有贡献时分两种情况. 1. 阅读全文
posted @ 2020-02-13 10:51 EM-LGH 阅读(128) 评论(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 阅读(167) 评论(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 阅读(127) 评论(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 阅读(113) 评论(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 阅读(119) 评论(0) 推荐(0)
摘要:第一次写这个题是好长时间以前了,然后没调出来. 本来以为是思路错了,结果今天看题解发现思路没错,但是好多代码细节需要注意. code: #include <cstdio> #include <vector> #include <map> #include <cstring> #include <al 阅读全文
posted @ 2020-02-09 15:27 EM-LGH 阅读(178) 评论(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 阅读(156) 评论(0) 推荐(0)
摘要:思路很巧妙啊 code: #include <cstdio> #include <cstring> #include <algorithm> #define ll long long #define N 1000009 #define setIO(s) freopen(s".in","r",stdi 阅读全文
posted @ 2020-02-06 16:42 EM-LGH 阅读(211) 评论(0) 推荐(0)
摘要:这个题的思路还是十分巧妙的. 我们发现我们要查询的区域恰好构成了一个梯形. 然后用那个单调栈去维护折线,并用主席树做二维数点. code: #include <cstdio> #include <algorithm> #include <stack> #include <cstring> #incl 阅读全文
posted @ 2020-02-06 15:44 EM-LGH 阅读(174) 评论(0) 推荐(0)
摘要:12种组合计数问题合在一起. code: #include <cmath> #include <cstring> #include <algorithm> #include <cstdio> #include <string> #define ll long long #define ull uns 阅读全文
posted @ 2020-02-04 15:04 EM-LGH 阅读(207) 评论(0) 推荐(0)
摘要:这道题很巧妙啊. 有两个性质: 1.一个图的最小生成树的每种边权数量是相等的. 2.有 1 得,如果任意一个最小生成树中边权为 $v$ 的边都断掉,$(x,y)$ 连通性在任意 MST 中都相等. 所以我们的做法就是先求出最小生成树,然后分别将每种边权 $v_{i}$ 从最小生成树中都断掉,得到若干 阅读全文
posted @ 2020-02-03 23:03 EM-LGH 阅读(161) 评论(0) 推荐(0)
摘要:矩阵树定理求的是 $\sum_{E} \prod_{e \in E} w(e)$ 平时我们求的大多数是方案数,所以就默认那个 $w(e)$ 是 $1$. 而如果我们想求所有生成树权值之和的话就让那个 $w(e)$ 变成边权. 我们在设置最开始的那个 (度数-邻接)矩阵的时候度数矩阵中 $S1_{i, 阅读全文
posted @ 2020-02-03 21:29 EM-LGH 阅读(136) 评论(0) 推荐(0)
摘要:求生成树方案的话要用矩阵树定理,然后这个容斥就是常见套路了吧. code: #include <cstring> #include <cstdio> #include <vector> #include <algorithm> #define N 18 #define mod 1000000007 阅读全文
posted @ 2020-02-03 19:10 EM-LGH 阅读(125) 评论(0) 推荐(0)
摘要:仔细观察样例解释,发现 $F(n)=2F(n-1)+[n \%2]$. 然后我们就可以推出来前 10 项左右的 $F(n)$ 的值,然后打表找规律发现 $F(n)=\frac{2^{n+1}}{3}$ (向下取整) 由于没有模数,所以需要手写一个 $FFT$ 维护高精度乘法的板子. code: #i 阅读全文
posted @ 2020-02-02 16:44 EM-LGH 阅读(129) 评论(0) 推荐(0)
摘要:code: #include <cstdio> #include <cstring> #include <algorithm> #define M 185 #define N 10000008 #define ll long long #define setIO(s) freopen(s".in", 阅读全文
posted @ 2020-02-02 10:53 EM-LGH 阅读(160) 评论(0) 推荐(0)

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 32 下一页