Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

有没有用点分治的大佬指点指点我

Posted by 1139784495 at 2017-01-26 20:17:09 on Problem 1741
思路是这样的:用树的点分治,先找重心,然后求经过重心的满足条件的路径数,然后递归子树。求经过重心的路径数,先dfs到重心的距离,再排序,然后线性求出数组里加起来<=k的数对个数,然而这样会有从一个子树出发再到这颗子树的情况,要剔除,剔除的话我用了递归,比如solve(p,k)表示以p为根的子树路径<=k的点对数,那么还要减去solve(v,p-2*w(p,v)),v是p的儿子。然而我先递归求解了子树,这之后判重数组就废了,怎么办……???

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator