[题解] 平衡树模板题,不过因为可以离线,所以有别的做法.把询问倒着做,变成删掉数字.求中位数,于是可以二分+树状数组. #include<cstdio> #include<cstring> #include<algorithm> #define LL long long #define rg register #define N 500010 using namespace std; int n,m,cnt,top,b[N],t[N],ans[N]; struct r…
P3871 [TJOI2010]中位数 一眼秒掉,这不是splay水题吗,套模板 #include<bits/stdc++.h> #define IL inline #define N 150005 using namespace std; ],siz[N],val[N],cnt[N],f[N],root,ncnt; IL void pushup(int k) { siz[k]=siz[ch[k][]]+siz[ch[k][]]+cnt[k]; } IL int chk(int x) { ]=…
今天这篇文章源于上周在工作中解决的一个实际问题,它是个比较普遍的问题,无论做什么开发,估计都有遇到过.具体是这样的,我们有一份高校的名单(2657个),需要从海量的文章标题中找到包含这些高校的标题,其实就是模糊查询(关注公众号 渡码, 回复关键词 trie 获取源码).对应的伪代码如下 selected_titles = [] for 标题 in 海量标题: for 高校 in 高校名单: if 标题.contains(高校): selected_titles.add(标题) break 如果是…
题目 :Bovine Genomics G奶牛基因组 传送门: 洛谷P3667 题目描述 Farmer John owns NN cows with spots and NN cows without spots. Having just completed a course in bovine genetics, he is convinced that the spots on his cows are caused by mutations in the bovine genome. At…