//#include //#pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include
核心就是vs序列存下的in[u],out[u]的中间段只有u的子树
做法肯定不是最优的,因为检查每个节点的深度我都用到了线段树查询,慢了3倍
换上树状数组肯定能更快,但我懒得学。。
双向边的编号修改难死我了。。。还好想出办法解决了
(其实是别人的代码我看不懂