摘要: "Tree" 参考 xk 老哥的博客: "POJ 1741 Tree 点分治" 找重心: cpp int d[maxn],dcnt; void dfs(int fa,int u,int w) { d[++dcnt]=w; siz[u]=1; for(int i=head[u];~i;i=e[i].n 阅读全文
posted @ 2019-08-14 22:23 caoanda 阅读(223) 评论(0) 推荐(0) 编辑
摘要: "F1. Complete the Projects (easy version)" "F2. Complete the Projects (hard version)" 参考: "Complete the Projects" 简单说就是当 b =0 是肯定是 a 小的优先的,需要注意的就是 b 需 阅读全文
posted @ 2019-08-14 15:14 caoanda 阅读(299) 评论(0) 推荐(0) 编辑
摘要: vector 开动态数组: 求一个数二进制中 1 的个数: 求一个数二进制中前缀 0 的个数: 求一个数二进制中后缀 0 的个数: 求 x 与 y 的 gcd: (需要头文件 algorithm) 补充: "一些奇奇怪怪的快捷小函数" 阅读全文
posted @ 2019-08-14 13:31 caoanda 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 持续更新... Wrong Answer 1. 数组开小了 2. 爆 int Time Limited Error 1. 数组开小了 2. 爆 int 3. 数组开得过大,有可能会导致 tle Runtime Error 1. 数组开小了 2. INTEGER_DIVIDE_BY_ZERO 除零错或 阅读全文
posted @ 2019-08-14 10:36 caoanda 阅读(172) 评论(0) 推荐(0) 编辑
摘要: "D2. Remove the Substring (hard version)" 思路:其实就是贪心吧,先从前往后找,找到 t 可在 s 中存在的最小位置 (pre),再从后往前找,找到 t 可在 s 中存在的最大位置(last),然后 last [ i+1 ] pre [ i ] 1 表示的即是 阅读全文
posted @ 2019-08-14 09:57 caoanda 阅读(157) 评论(0) 推荐(0) 编辑
摘要: "Housewife Wind" 参考博客: "POJ2763 Housewife Wind(树剖+线段树)" 差不多是直接套线段树+树剖的板子,但是也有一些需要注意的地方 建树: cpp void update(int x,int s,int t,int k,int p) { if(s==t) { 阅读全文
posted @ 2019-08-13 18:50 caoanda 阅读(167) 评论(0) 推荐(0) 编辑
摘要: "A Aragorn's Story" 直接套 "线段树+树剖" 板子 代码: cpp // Created by CAD on 2019/8/12. include define lson (p 1; build(l,m,lson),build(m+1,r,rson); d[p]=d[lson]+ 阅读全文
posted @ 2019-08-12 22:44 caoanda 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 其实树状数组和线段树写树剖都差不多,只是换了一种储存数据的方式,一种占用空间小,但是相对耗时,一种占用空间大,但是很快。 模板题: "树链剖分" 用树状数组会 tle 但是这也是一种思路 cpp // Created by CAD on 2019/8/11. include using namesp 阅读全文
posted @ 2019-08-12 19:06 caoanda 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 模板题: "树链剖分" 参考博客: "树链剖分详解(洛谷模板 P3384)" 前置技能: "线段树" cpp void build(int s,int t,int p) { if(s==t) { d[p]=wt[s]%mod; / 此处wt[]是排序好之后的序号对应的权重 / return; } i 阅读全文
posted @ 2019-08-12 18:35 caoanda 阅读(211) 评论(0) 推荐(0) 编辑
摘要: "E. Compress Words" 直接套 KMP 即可(那为什么打 cf 的时候没有想到...),求出后一个单词(word)的前缀数组,然后从前面已得的字符串的末尾 word. length () 开始查询利用 "前缀数组" 进行优化即可 代码: cpp // Created by CAD o 阅读全文
posted @ 2019-08-12 16:12 caoanda 阅读(204) 评论(0) 推荐(0) 编辑