随笔分类 - 题解
摘要:带修改莫队板子 块长取 \(O(n^{\frac 2 3})\) 总时间复杂度为 \(O(n^{\frac 5 3})\) \(\text{Code}\) #include <cstdio> #include <cmath> #include <algorithm> #include <iostre
        阅读全文
                
摘要:\(\text{Solution}\) 明显的 \(\text{K-D Tree}\) 基操题 提前给出了数列,那么考虑提前建好树,省去重构 但还是要开 \(O\) \(\text{Code}\) #pragma GCC optimize(3) #pragma GCC optimize("inlin
        阅读全文
                
摘要:\(\text{Code}\) #include <cstdio> #include <iostream> #include <algorithm> #define re register using namespace std; const int N = 2e5 + 5; const doubl
        阅读全文
                
摘要:\(\text{Solution}\) 一个性质:两个 \(K\) 元组有边相连当且仅当每个点在对应的图中到 \(1\) 有奇偶性相同的路径 那么我们就可以预处理每个图中的点到 \(1\) 的奇偶最短路 再考虑路径长度,显然是 \(\min(\max_{i=1}^k{odd_i}, \max_{i=
        阅读全文
                
摘要:\(\text{Solution}\) 线段树分治的模板 对时间分治,线段树下标表示时间 在线段树上处理每条覆盖当前区间的边,对当前的时间区间求答案 小区间的信息可以由大区间一路下来得到,那么答案就是叶子节点的答案 对于二分图的加边动态判定,可以用并查集维护 具体来说就是用带权并查集,维护每个点与其
        阅读全文
                
摘要:\(\text{FFT}\) #include <cstdio> #include <cmath> #include <iostream> #include <cstring> #define re register using namespace std; const int N = 2e6 + 
        阅读全文
                
摘要:\(\text{Solution}\) 一个点可与另一个颜色相同点同时涂色当且仅当两点间颜色都大于等于这两点 那么我们可以预处理一个点向左向右最远能到的位置,记为 \(l_i,r_i)\) 当 \(l_i = l_j \text{ and }r_i = r_j\) 时,\((i,j)\) 就可以同时
        阅读全文
                
摘要:\(\text{Solution}\) 发现每个时刻的状态一定是所有点在一个最外围三角形的内部 设 \(f_{i,j,k,p}\) 表示排列填到第 \(p\) 位,此时图形最外围的三角形是以编号为 \(i,j,k\) 的三角形的方案数 那么考虑这个三角形是怎么来的,于是又两个转移 1.前 \(1~p
        阅读全文
                
摘要:\(\text{Solution}\) 简要的口胡 线段树维护合法左端点数量 正序枚举 \(i\),将其视为右端点,去除不合法的左端点,统计贡献 再将其视为中间点,由它产生的左端点在线段树上区间加 注意到一个重复出现的 \(b\) 值,上一个相同位置的贡献不能再要 于是把这个点废掉 考场上又打了棵线
        阅读全文
                
摘要:\(\text{FFT}\) 模板 #include <cstdio> #include <iostream> #include <cmath> #define re register using namespace std; const int N = 2e6 + 1e5; int rev[N],
        阅读全文
                
摘要:贴模板 注意:\(\text{id}\) 表示第二关键字排序后(其实无需排序,利用上轮的 \(\text{sa}\) 值即可)相应的第一关键字的位置 计数排序为了稳定性最后确定位置时要倒着开始 复制的 \(\text{ork}\) 要开两倍 \(\text{Code}\) #include <cst
        阅读全文
                
摘要:\(\text{Problem}\) \(\text{Solution}\) 纪念我考场正解被二分暴力暴踩。。。 首先二分的话,显然可以二分出答案,然后数矩阵和大于等于本矩阵的是否有 \(k\) 个 加一些优化就可以 \(AC\)?!! 不管它,正解就是让矩阵行列大小从小到大扩展,矩阵和小一些的肯定
        阅读全文
                
摘要:\(\text{Problem}\) \(\text{Solution}\) 最优解一定是一个回文子串的最优构造加上剩下的逐个填入 考虑用回文树建出所有的回文串,然后 \(dp\) 求回文子串最优的构造方案 维护一个 \(\text{half}\) 意义同 \(\text{fail}\),但要保证长
        阅读全文
                
摘要:\(\text{Code}\) #include<cstdio> #include<cstring> #include<iostream> #define LL long long #define re register using namespace std; const int N = 3e5 
        阅读全文
                
摘要:\(\text{Problem}\) \(\text{Solution}\) 考虑 \(60\) 分 设 \(f_{i,j,k}\) 表示前 \(i\) 个数,模 \(j\) 同余 \(k\) 的个数 由于空间太大,离线后把询问 \(l,r\) 拆开,挂到相应的位置上 然后按位置顺着扫一遍即可 考虑
        阅读全文
                
摘要:\(\text{Problem}\) 一年一度的高考结束了,我校要拍集体照。本届毕业生共分 \(n\) 个班,每个班的人数为 \(A_i\)。这次拍集体照的要求非常奇怪:所有学生站一排,且相邻两个学生不能同班。现在,安排这次集体照的老师找到了你,想问问你一共有多少种方案。方案数可能很大,最终结果对 
        阅读全文
                
摘要:\(\text{Solution}\) \(dp\) 翻折就只需预处理回文中心 \(Manacher\) 预处理即可 \(Code\) #include<cstdio> #include<iostream> #define LL long long using namespace std; cons
        阅读全文
                
摘要:\(\text{Solution}\) \(30\) 分暴搜合法路径 另 \(30\) 分状压 设 \(f_{i,j,k}\) 表示当前到第 \(i\) 个点,走过的点状态为 \(j\),走过的路径长度为 \(k\) 的方案数 \(100\) 分仍然回到暴搜 考虑折半搜索,把路径拼起来,先搜一次,哈
        阅读全文
                
摘要:\(\text{Problem}\) 有向不联通图,求每个子图至多选出一条最大权值和的路径,求前 \(k+1\) 个 \(\text{Solution}\) 显然将每个子图缩点后 \(dp\),排序 \(dp\) 值即可 很多细节要处理 \(\text{Code}\) #include<cstdio
        阅读全文
                
摘要:\(Tarjan\) 模板 #include<cstdio> #include<queue> #include<iostream> #define re register using namespace std; const int N = 1e4 + 5; int n, m, a[N], h1[N
        阅读全文
                

浙公网安备 33010602011771号