随笔分类 -  主席树

ZOJ 2112 Dynamic Rankings (动态第k大,树状数组套主席树)
摘要:Dynamic RankingsTime Limit:10 Seconds Memory Limit:32768 KBThe Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the k-th smallest number of the given N numbers. They have developed a more powerful system such that for N numb 阅读全文

posted @ 2013-09-08 10:32 kuangbin 阅读(6473) 评论(0) 推荐(2)

SPOJ 10628. Count on a tree (树上第k大,LCA+主席树)
摘要:10628. Count on a treeProblem code: COTYou are given a tree withNnodes.The tree nodes are numbered from1toN.Each node has an integer weight.We will ask you to perform the following operation:u v k: ask for the kth minimum weight on the path from nodeuto nodevInputIn the first line there are two inte 阅读全文

posted @ 2013-09-07 07:42 kuangbin 阅读(2096) 评论(0) 推荐(0)

SPOJ 3267. D-query (主席树,查询区间有多少个不相同的数)
摘要:3267. D-queryProblem code: DQUERYEnglishVietnameseGiven a sequence of n numbers a1, a2, ..., anand a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the subsequence ai, ai+1, ..., aj.InputLine 1: n (1 ≤ n 阅读全文

posted @ 2013-09-06 12:15 kuangbin 阅读(2487) 评论(0) 推荐(0)

POJ 2104 && POJ 2761 (静态区间第k大,主席树)
摘要:查询区间第K大,而且没有修改。使用划分树是可以做的。作为主席树的入门题,感觉太神奇了,Orz 1 /* *********************************************** 2 Author :kuangbin 3 Created Time :2013-9-4 20:13:20 4 File Name :POJ2104.cpp 5 ************************************************ */ 6 7 #include 8 #include 9 #include 10 #incl... 阅读全文

posted @ 2013-09-05 10:29 kuangbin 阅读(3782) 评论(0) 推荐(0)

导航

JAVASCRIPT: