
主席树
Loi_a
这个作者很懒,什么都没留下…
展开
-
poj2104 K-th number 主席树模版
这个题以前分块做,学了主席树(抄模版),存一下;#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int a[100005]; int L[100005]; struct zxs{ int l,r,cnt; }tree[5000005]; int tot=1; int rt[100005]原创 2016-08-16 09:54:07 · 363 阅读 · 0 评论 -
bzoj3524/2223 主席树
给一个长度为n的序列a。1≤a[i]≤n。 m组询问,每次询问一个区间[l,r],是否存在一个数在[l,r]中出现的次数大于(r-l+1)/2。如果存在,输出这个数,否则输出0。 #include<iostream> #include<cstdio> using namespace std; struct zxs{ int l,r,cnt; }tree[10000005]; int t原创 2016-12-19 08:31:06 · 515 阅读 · 0 评论 -
bzoj2588 count on a tree 主席树
在树上建主席树,每个点以它的父亲节点作为历史版本。#include<iostream> #include<cstdio> #include<algorithm> #define maxn 200005 using namespace std; struct E{ int to,nxt; }b[maxn<<1]; int fst[maxn],tot=1; void build(int f,in原创 2016-12-20 07:44:58 · 485 阅读 · 0 评论