Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
有没有用点分治的大佬指点指点我思路是这样的:用树的点分治,先找重心,然后求经过重心的满足条件的路径数,然后递归子树。求经过重心的路径数,先dfs到重心的距离,再排序,然后线性求出数组里加起来<=k的数对个数,然而这样会有从一个子树出发再到这颗子树的情况,要剔除,剔除的话我用了递归,比如solve(p,k)表示以p为根的子树路径<=k的点对数,那么还要减去solve(v,p-2*w(p,v)),v是p的儿子。然而我先递归求解了子树,这之后判重数组就废了,怎么办……??? Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator