01 2018 档案
摘要:treap。树是以“优先级”(优先级越小,在书架上越靠上)形成的,堆是以rand()的权值形成的。还要再维护一个原编号。 置顶/置底:找到那个元素,把它拉出来修改优先级再塞回去。 insert:即一个元素和他“附近”的元素交换位置,把他们两个拉出来,交换优先级再塞回去 cpp include inc
阅读全文
摘要:先满足挑剔的 cpp include include include include using namespace std; typedef long long ll; int n, m, tmp, rot, cnt; ll ans; struct Cow{ int pri, gre; }cow[
阅读全文
摘要:treap水过 cpp include include include using namespace std; int n, uu, rot, cnt, sum=0, ans1, ans2; const int oo=2147483647; struct Treap{ int val[35005]
阅读全文
摘要:学校linux机子根本跑不动libreoffice,wps没有公式,只好上LaTeX了。 先 beamer: 需要安装firasans和firamono字体,思源黑体SC \documentclass[10pt]{beamer} \usetheme[progressbar=frametitle]{m
阅读全文
摘要:参考文章 "无源汇有上下界的可行流" "有源汇有上下界的最大流" "有源汇有上下界的最小流" 无源汇有上下界可行流 以 loj115 为例。 剥离出必要边与自由边。 cpp include include include include using namespace std; int n, m,
阅读全文
摘要:考虑暴力,答案显然是 $\sum_{i=1}^n\sum_{j=1}^m(2(\gcd(i,j) 1)+1)=\sum_{i=1}^n\sum_{j=1}^m(2\gcd(i,j) 1)$。 考虑优化,设 $f(i)$ 是 $\gcd(x,y) = i$ 的点的个数,则 $\sum_{i=1}^{\
阅读全文
摘要:先二分一下变成判定性问题。 在 $1 \ldots n$ 内,所有的没有平方因子的数的个数是: $$n \frac{n}{2^2} \frac{n}{3^2} \cdots + \frac{n}{(2 \times 3)^2} + \cdots $$ 惊奇地发现也就是 $$\sum_{k=1}^{\
阅读全文
摘要:莫比乌斯反演练习题。 cpp include include include using namespace std; typedef long long ll; int T, b, d, a, c, k, mu[100005], pri[100005], cnt; bool isp[100005]
阅读全文
摘要:参考资料 1. "PoPoQQQ的PPT" 2. "莫比乌斯反演定理证明" 3. "莫比乌斯反演简要笔记" 定义 $$f(n)=\sum_{d|n}g(d) \Rightarrow g(n)=\sum_{d|n} \mu(d)f(\frac{n}{d}).$$ 更常用的:$$f(n)=\sum_{n
阅读全文
摘要:对每一个宗教建一棵线段树,然后树剖搞搞 cpp include include using namespace std; int n, m, w[100005], c[100005], uu, vv, hea[100005], cnt, dep[100005]; int fa[100005], to
阅读全文
摘要:树状数组不用动脑子真爽啊 cpp include include include using namespace std; typedef long long ll; int m, n, b[100005], rem, rot[100005], lson[20000005], rson[200000
阅读全文
摘要:前置技能:Count on a tree 然后带上一个启发式合并 cpp include include include using namespace std; int n, m, orz, uu, vv, ww, a[80005], b[80005], rnk[80005], rem, cnt,
阅读全文
摘要:前置技能 :HDU3376 Matrix Again 所以看到这个题,我们也会想着用最大费用最大流解决,因为从起点飞到终点再飞回来,就等于从起点飞两次到终点且这两次飞行除了起点终点之外没有访问超过一次的点。 考虑拆点限流,除起点终点以外的点容量是1(花费代表边权),起点终点容量是2。 输出方案的话,
阅读全文
摘要:最大费用最大流 咋写?取个相反数就可以了……
阅读全文
摘要:设dp[i][j][k]表示前i个数中选j个并且因子含有k个2的能获得的最多的5的个数 则dp[i][j][k]=max(dp[i 1][j][k],dp[i 1][j 1][k cnt2]+cnt5) 滚掉一维 cpp include include include using namespace
阅读全文
摘要:先算出一个点前头比它大和后头比它小的数量。 每次删点就扔进一个主席树里头,防止造成重复删答案。 cpp include include include using namespace std; int n, m, a[100005], p[100005], c[100005], uu, pre[10
阅读全文
摘要:主席树放到树上而已 cpp include include include using namespace std; int n, m, lstans, uu, vv, a[100005], b[100005], rnk[100005], rem, cnt; int lson[2200005], r
阅读全文
摘要:大水题 cpp include include using namespace std; int n, du[100005], hea[100005], cnt, uu, vv; double dp[100005]; struct Edge{ int too, nxt; }edge[200005];
阅读全文
摘要:把前缀和换成树状数组 cpp include include include using namespace std; int n, m, a[10005], b[20005], rem, cnt, sum[2100005], lson[2100005], rson[2100005], rot[10
阅读全文
摘要:倘若存在 1,那么答案是 $n cnt_1$。 否则,设最短的公约数为 1 的区间长度为 $minlen$,答案是 $minlen 1+n 1$。 cpp include include using namespace std; int n, ans, gcd[2005][2005], cnt; i
阅读全文
摘要:明确几点 1. 假设有串 ab,那么 a 后头必须是 b,b 前头必须是 a,否则就不是最频繁的了。 2. 不可成环,aba是非法的。 cpp include include include include using namespace std; int n, len, ru[35], chu[3
阅读全文
摘要:区间上有 $n$ 个点,问你为达到目的:长度为 $m$ 的区间内点的个数都 $ include include include include using namespace std; int n, m, k, a[200005], cnt; queue q; int main(){ cin n m
阅读全文
摘要:把 里的 前面那个 去掉,终端就有高亮啦qwq!(然后source一下 然后 然后加入 (为什么不改 呢?我 WC 的时候发现自己并不能 QAQ) 然后把终端背景改个好看的。NOI Linux 下背景在 (差不多是这个位置) 如果是 Windows 的 gVim 再加入 前两行设置了字体。顺便,把配
阅读全文
摘要:模板题 cpp include include include include using namespace std; int n, m, hea[5005], cnt, uu, vv, ans; double e, ww, dis[5005]; const double eps=1e 7; bo
阅读全文
摘要:注意把书拆成两份 cpp include include include include using namespace std; int nb, nc, na, hea[40005], cnt, cur[40005], ss, tt, uu, vv, ww, maxFlow; int lev[40
阅读全文
摘要:注意一个景点只能去一次。 cpp include include include include include using namespace std; int n, m, xx[205], yy[205], hea[205], ss, tt, cnt, lev[205], maxFlow; co
阅读全文
摘要:前置技能:poj3041 如果是二维平面有一些方块,这些方块被染了黑色,你每次可以选择 $(x,y)$ 的区域染成白色,代价是 $\min(x,y)$,问你付出的最小代价 显然我们不会这么染 因为这样我们的代价是 $\min(x,y)$,为了研究的方便我们假设 $x$ 比 $y$ 小,那我们就相当于
阅读全文
摘要:二分图。对于每个点,将他的 x 与 y 连一条边,求最小点覆盖 二分图最小点覆盖等于最大匹配 include include include using namespace std; int n, k, hea[505], cnt, lnk[1005], ans, uu, vv; bool vis[
阅读全文
摘要:```cpp include include include using namespace std; int n, e[10005][2], lnk[20005], d, ans[10005]; bool vis[20005]; bool dfs(int x){ for(int i=0; i n;
阅读全文
摘要:维护区间左颜色值,右颜色值,颜色段个数。 cpp include include using namespace std; int n, m, uu, vv, ww, w[100005], wt[100005], qwq, idx[100005], hea[100005]; int cnt, dep
阅读全文
摘要:关于空间,第零棵树是 $4n$,其后每棵树都要多来 $\log(n)$ 的空间,所以我是开 $n(4+\log(n))$ 的空间。 关于借用节点: 图片来自 "这里" cpp include include include using namespace std; int n, m, rot[200
阅读全文
摘要:题解看 "这里" cpp include include include using namespace std; int t, maxp, w, dp[2005][2005], qaq[2005], haq, taq, ap, bp, as, bs, ans; int main(){ cin t
阅读全文
摘要:和「理想的正方形」比较相似,需要先掌握那道题。 花坛外头每一边必须套上绿化带 cpp include include using namespace std; int n, m, a, b, c, d, qwq[1005], twq, hwq, zzxz[1005][1005], ans; int
阅读全文
摘要:先对于每一行中长度为 n 的列用单调队列搞出它们的最小/大值,再将这些长度为 n 的列想象成点再对行跑一遍 cpp include include include using namespace std; int a, b, n, r[1005][1005], qwq[1005], qaq[1005
阅读全文
摘要:神题,还不太清楚 cpp include include include include using namespace std; int n, m, hea[1005], cnt, uu, vv, ww, minCost, pre[1005], dis[1005], ss, tt; const i
阅读全文
摘要:修车加强版 边跑边加,有个师傅做到第 i 个(相对他自己而言),就给他加到 i+1 个。 cpp include include include include using namespace std; int n, m, p, ss, tt, uu, hea[85005], cnt, tim[45
阅读全文
摘要:想象一下,要搞掉一个植物,必须先搞掉另一些植物……我们可以发现这是一个最大权闭合子图的问题。 最大权闭合子图的话,太空飞行计划问题是一个入门题,可以一看。 然而我们手玩一下样例就会惊恐地发现,保护关系 出现了环 。 比如说: 从 i 到 j 的箭头是说要搞 i 就要先搞 j,这是为了和最大权闭合子图
阅读全文
摘要:其实,只用考虑某一行能否放到某一行就行了 cpp include include include using namespace std; int T, n, a[205][205], hea[405], cnt, ans, lnk[405]; bool vis[405]; struct Edge{
阅读全文
摘要:poorpool 真名 chenyixiao。是一条傻逼题都不会做的没有脑子的咸鱼。 现就读于华中科技大学计算机科学与技术学院,曾为山西省临汾第一中学校选手,NOIP 2017&2018 一等奖,WC 2018 无奖,SXOI 2018 暴力进队,APIO 2018 铜牌,THUSC 2018 未进
阅读全文
摘要:安装就把根节点到它全设为 1 删除就把以它为根的子树全设为 0 记得 标记初始化为 1 ,因为标记是 0 的情况也是要处理的。
阅读全文
摘要:二分图匹配,一边是属性值,一边是武器 cpp include include include using namespace std; int n, lst[1010005], uu, vv, hea[10005], cnt, ans; bool vis[1010005]; struct Edge{
阅读全文
摘要:参考 "这里" 我们先预处理模数在 $\sqrt{n}$ 以内的询问。 要是模数在 $\sqrt{n}$ 以外,直接暴力统计,反正这样的数又不会超过 $\sqrt{n}$ 个。 修改的时候也是。要是在 $\sqrt{n}$ 以内就把预处理的答案减去原数加上新数。 然后再把原数改掉。 然后再优化一下,
阅读全文
摘要:先做一遍普通的dinic 然后再更改源点为超级源,超级源向原源加一条capacity=k && cost=0的边,再加上有费用的边跑最小费用最大流 cpp include include include include using namespace std; int n, m, k, ss, tt
阅读全文
摘要:把每个点拆成 x y z 对于第 i 个点,x y是表示流入的,y z是表示流出的。 cpp include include include include using namespace std; int n, m, ss, tt, hea[1305], cnt, minCost, pre[130
阅读全文
摘要:巨水,调了好久,心态爆炸 cpp include include include using namespace std; typedef long long ll; int n, m; const int mod=9999973; ll dp[105][105][105]; inline int
阅读全文
摘要:num[x]表示x到达叶子最远路径。 每个子节点对答案的贡献是num[x] (num[t] + edge[i].val) cpp include include using namespace std; typedef long long ll; int n, ss, hea[500005], cn
阅读全文
摘要:学习位运算 cpp include include using namespace std; int n, m, dp[15][4105], a[15], uu, ans; const int mod=100000000; int main(){ cin m n; for(int i=1; i
阅读全文
摘要:对于每个点,把它拆成有权值为1的边相连的两个点,原边是inf。 边的起点统一加n,ss也加n 这就成了最小割 cpp include include include include using namespace std; int n, m, ss, tt, hea[205], cnt, uu, v
阅读全文
摘要:先差分一下,钦定一个模式串,答案是这个模式串的所有后缀与其它串的最小的相同的的最大的。 cpp include include include using namespace std; int n, a[1005][1005], len[1005], nxt[1005], ans=0; void g
阅读全文
摘要:不相同子串个数。 参考那篇论文。 cpp include include include using namespace std; int n, m, p, x[1005], y[1005], c[1005], sa[1005], rnk[1005], hei[1005]; int ans, T;
阅读全文
摘要:参考那篇经典论文。 cpp include include include using namespace std; int n, k, r[20005], x[20005], y[20005], sa[20005], rank[20005], hei[20005]; int m=1000005,
阅读全文
摘要:```cpp include include include include using namespace std; int T, n, m, p, len, r[20005], c[20005], x[20005], y[20005], sa[20005]; int rank[20005], a
阅读全文
摘要:"ref" and 挑战程序设计竞赛。 ~~主要是发现自己以前写得代码太难看而且忘光了,而且我字符串死活学不会啊,kmp这种东西我都觉得是省选+难度啊QAQ~~ cpp include include include using namespace std; int n, cnt[1000005],
阅读全文
摘要:```cpp #include #include #include #include using namespace std; int n, m, uu, vv, dy[100005]; double dp[100015]; int main(){ while(scanf("%d %d", &n, &m)!=EOF){ if(!n && !m) break; memset(dp,...
阅读全文
摘要:讲解看 "这里" 交 C++
阅读全文
摘要:```cpp include include include include using namespace std; int n, m, uu, vv, ww, a[105], cnt, hea[10005], gra[10005], siz[10005]; int tot, sze, rot;
阅读全文
摘要:点分治裸题 cpp include include using namespace std; int n, uu, vv, ww, ans, cnt, hea[20005], rot, gra[20005], sze, qwq[5]; int siz[20005], gcd; bool vis[20
阅读全文
摘要:"参考博文" 带一点容斥的思想 cpp include include include include using namespace std; struct Edge{ int too, nxt, val; }edge[20005]; int n, k, uu, vv, ww, cnt, sze,
阅读全文
摘要:把m个师傅拆成n个阶段,考虑每个人选上第某个阶段的某师傅对答案做出的贡献。 参见 "这里" 与 "那里" 。 cpp include include include include using namespace std; int m, n, uu, cnt, hea[605], ss, tt, m
阅读全文
摘要:排序枚举左端点,则右端点必定不降 cpp include include include include using namespace std; struct Node{ int pos, val; }nd[1000005]; int n, k, cnt[63], uu, vv=0, rig=0,
阅读全文
摘要:纪念一下独立AC紫题。 最近在学树剖,就忘了差分了……所以效率比较低 cpp include include using namespace std; int n, uu, vv, a[300005], hea[300005], dep[300005], gnd[300005][21], qwq;
阅读全文
摘要:莫队裸题还不带修改 cpp include include include include using namespace std; int n, m, qcnt, ans, col[1000005], bse, blc[50005], a[50005], qwq[200005]; struct Q
阅读全文
摘要:莫队算法模板 推荐阅读 "这篇博客" cpp include include include include using namespace std; int n, m, bse, blc[10005], a[10005], qCnt, cCnt, qwq[10005], ans=0; int cn
阅读全文
摘要:题解参照 "这里" 每个研究完记得乘一个1/n,这是乘了概率。 cpp include include using namespace std; double dp[105][33005]; int n, k, p[25], d[25], uu; int main(){ cin k n; for(i
阅读全文
摘要:要想限制流量,总要想着拆点。 cpp include include include include using namespace std; int n, m, ss, tt, uu, vv, ww, maxFlow, minCost, cnt, hea[405], pre[405]; int d
阅读全文
摘要:单调队列+二分答案 cpp include include include include using namespace std; struct Node{ int x, y; }nd[100005]; int n, d, ans, q1[100005], q2[100005], l1, r1,
阅读全文
摘要:参考胡伯涛论文,真是个好东西! 最大流=最小割 最大权闭合图=总正权值 “最小简单割” 太空飞行计划问题 最小点权覆盖集=“最小割” 覆盖集与独立集互补 最大点权独立集=总权 最小点权覆盖集 最小点覆盖数 = 最大匹配数
阅读全文
摘要:最大点权独立集,参见胡伯涛论文 cpp include include include include using namespace std; int m, n, a[105][105], hea[10005], ss, tt, tot, maxFlow, lev[10005], cnt; con
阅读全文
摘要:裸题 cpp include include using namespace std; typedef long long ll; int n, m, ecnt, hea[100005], dep[100005], top[100005], idx[100005], cnt; int fa[1000
阅读全文
摘要:第一问DP水过。dp[i]代表以i结尾的最长不下降子序列长度。 二三问网络流。 第二问是说每个子序列不能重复使用某个数字。 把每个点拆成p(i),q(i)。连边。 要是dp[i]=1,连源,p(i) 要是dp[i]=s,连q(i),汇 要是i include include include usin
阅读全文
摘要:大约是第一次做近几年NOI题(尽管是签到题)? 制作一个真值表,要是有哪一位原本是0但是能变成1那真是太好啦,要是有哪一位原来是1能变成1并且算上它不会超过m那也不错。 cpp include include using namespace std; int zz1, zz2, n, m, t, a
阅读全文
摘要:使用long double
阅读全文
摘要:1日 luogu 2590 luogu 2393 2394 luogu 2114 2日 luogu 2766 luogu 3178 luogu 2774 luogu 2698 3日 luogu 2153 luogu 1291 luogu 2473 luogu 1903 1972 luogu 3258
阅读全文

浙公网安备 33010602011771号