
数据结构_主席树
just_sort
Acdream.
展开
-
主席树的读书笔记
***********************************************声明************************************************ 原创作品,出自 “晓风残月xj” 博客,欢迎转载,转载时请务必注明出处(http://blog.youkuaiyun.com/xiaofengcanyuexj)。由于各种原因,可能存在诸多不足,欢迎斧转载 2016-08-20 17:03:22 · 397 阅读 · 0 评论 -
Educational Codeforces Round 26 G. Functions On The Segments 主席树
题目链接:http://codeforces.com/contest/837/problem/G题意:给了n个分段函数,然后给m个查询,每次查询查[l,r]的f(x)的和,强制在线。解法:关键是找到一个可以求前缀信息的数据结构,主席树显然满足,这题就是主席树的应用。#include using namespace std;typedef long long LL;原创 2017-08-07 16:27:18 · 383 阅读 · 0 评论 -
HDU 4417 线段树离线&&主席树在线
Problem Description Mario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lover. W原创 2017-02-27 17:29:19 · 938 阅读 · 0 评论 -
CF 787E 主席树上二分,或者离线BIT
题目链接:http://codeforces.com/contest/786/problem/C 题意:给了一个长度为n的数列,现在要问你对于每个k,k从取到n,最少可以把n分成多少段,使得每一段里面的颜色总数<=k。 解法: 所以我们倒着建主席树,然后在主席树上二分就可以对于每一个k用两个log查询到答案了。顺着建立主席树的话,你还要二分右端点,这样的话是3个log,不知道是否能过,稍加转化原创 2017-03-25 14:58:28 · 851 阅读 · 0 评论 -
SPOJ D-query 树状数组离线&&主席树在线
Given a sequence of n numbers a1, a2, …, an and 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 sub原创 2017-02-27 11:50:07 · 421 阅读 · 0 评论 -
POJ 2104 K-th Number 区间第K大,可持久化线段树
Description You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to原创 2017-02-26 10:17:57 · 558 阅读 · 0 评论 -
Bzoj 1901 Dynamic Rankings
【题意】Description给定一个含有n个数的序列a[1],a[2],a[3]……a[n],程序必须回答这样的询问:对于给定的i,j,k,在a[i],a[i+1],a[i+2]……a[j]中第k小的数是多少(1≤k≤j-i+1),并且,你可以改变一些a[i]的值,改变后,程序还能针对改变后的a继续回答上面的问题。你需要编一个这样的程序,从输入文件中读入序列a,然后读入一系列的指原创 2016-08-22 10:25:19 · 683 阅读 · 0 评论 -
Codeforces Round #433 题解
比赛链接:http://codeforces.com/contest/854A. Fraction解法:按照题意模拟即可。#include using namespace std;int main(){ int n; cin >> n; for(int i=n/2; i>=1; i--){ if(__gcd(i, n-i) == 1){原创 2017-09-24 09:51:07 · 353 阅读 · 0 评论