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

很有趣的一点,100次询问,预处理会TLE,直接暴力100次却不会

Posted by saikyou at 2016-05-01 18:04:12 on Problem 2114 and last updated at 2016-05-01 18:11:48
分治维护深度(距离)表的时候,不用O(nlogn)排序+O(n)解决长度和为询问值的点对的个数,而是把每一种可能的点对的距离和都加入(或移出)STL map

这样预处理是O(n^2),但事实上远达不到上界,因为一棵树不可能像稠密图一样,每张表长度都是n,而且因为分治的缘故,表的长度会以对数级减少,map上的查询是O(logn),整体应该不到O(n^2)

而直接暴力100次是O(100*n*logn*logn),因为100比较小可以视为一个常数级的改变

但是预处理还是超了

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