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 |
此题有O(q+mlogm)的算法(设序列中不同值的个数为m)每次询问不需要O(logn)复杂度。 只要从小到大记录这个序列每个值的起始位置、结束位置和频数(即离散化),对频数进行rmq即可,每次询问只用O(1)的复杂度,300多ms就可以过了。 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator