摘要:
dfs序七个经典问题 参考自:《数据结构漫谈》 许昊然 dfs序是树在dfs先序遍历时的序列,将树形结构转化成序列问题处理。 dfs有一个很好的性质:一棵子树所在的位置处于一个连续区间中。 ps:deep[x]为x的深度,l[x]为dfs序中x的位置,r[x]为dfs序中x子树的结束位置 1.点修改 阅读全文
摘要:
You are given an array d1,d2,…,dn consisting of n integer numbers. Your task is to split this array into three parts (some of which may be empty) in s 阅读全文
摘要:
1.POJ上G++只能用 %f,C++可以%lf 2.连续区间异或和最大,我只会一个套路,就是01字典树了! 3.行和列是无关的,因此有时候可以把棋盘原题分解成两个一维问题。r[N]、c[N]... 4.线段树:当前区间加上了懒惰标记的值实际上加的值是lazy_tag 区间长度 5.线段树:成段更新 阅读全文
摘要:
Polycarp is practicing his problem solving skill. He has a list of n problems with difficulties a1,a2,…,an, respectively. His plan is to practice for 阅读全文
摘要:
Polycarp has n coins, the value of the i th coin is ai. It is guaranteed that all the values are integer powers of 2 (i.e. ai=2d for some non negative 阅读全文