树链剖分
(0.)漏掉(build) (dfs)
(1. cnt=1)漏掉
(2.size[u]+=size[v])漏掉
(3.)应该先(dfs)再(build),写反了
(4.while(top[x]!=top[y]))的循环里写(if(... ) swap(x,y))
(5.update)里也要写(pushdown())
(6.)先连边再(dfs()) (build())
(7.dfs(son[u],topf))不是(dfs(u,topf))
(8.)交换前比较大小时搞清是大于还是小于
LCA
(1.)漏掉(work(),dfs())
其他
(1.)(最好不要用(while(1)))
(2.)输出的答案之间是换行还是空格
(3.)边界问题,如下标是不是会超出(n)
(4.)不要写(log),写(log2)
(5.)不开(long) (long)见祖宗
(6.)认真读题,如(n<=2*m),如从0到(n-1)编号
(7.)对于贪心分段的问题,有可能一个点的数值就超过限制。
(8.)(log)函数写成(log2)
(9.)数组尽量大,一定保证不RE!!
(10.)用多次单调队列是一定要记得(l),(r)清零,注意(q1)对应(l1)
(11.)样例可能比较特殊(如有序、全部相等、(n==m))
(12.)多组数据尽量都清空(如队列、栈,不要只清空(l),(r),(top)之类的)
(13.)(memset)的(sizeof)的括号里是数组名,不是0
(14.)是(<=m),还是(<=n)!
(15.)见棋盘制作后的反思
( 悬线法时,不一定取到一个点向...延伸的最远距离
(16.)i=head[u]不要写成i=head[i]
(17.)调样例的时候也开上long long 吧
(18.)随手保存代码
(19.)
重点
(1.)判负下标
(2.)除数不能是0
(3.)写(while)的时候要判是否越界,如 while(t<=n&&...)