[题目] 查询区间和,如果区间元素重复出现则计数一次. 链接:https://ac.nowcoder.com/acm/contest/1084/B [题解] 将询问按r排序,维护每个数最后出现的位置,并用树状数组维护前缀和即可 AC代码: #include<bits/stdc++.h> using namespace std; #define int long long #define lowbit(x) (x&(-x)) #define N 500009 int n,m; int a…
树状数组维护DP + 高精度 Description These days, Sempr is crazed on one problem named Crazy Thair. Given N (1 ≤ N ≤ 50000) numbers, which are no more than 109, Crazy Thair is a group of 5 numbers {i, j, k, l, m} satisfying: 1 ≤ i < j < k < l < m ≤ N Ai…
Bobo has a balanced parenthesis sequence P=p 1 p 2…p n of length n and q questions. The i-th question is whether P remains balanced after p ai and p bi swapped. Note that questions are individual so that they have no affect on others. Parenthesis se…
题目描述 这是一道模板题,其数据比「普通平衡树」更强. 如未特别说明,以下所有数据均为整数. 维护一个多重集 S ,初始为空,有以下几种操作: 把 x 加入 S 删除 S 中的一个 x,保证删除的 x 一定存在 求 S 中第 k 小 求 S 中有多少个元素小于 x 求 S 中小于 x 的最大数 求 S 中大于 x 的最小数 操作共 n 次. 输入格式 第一行一个整数 n,表示共有 n 次操作 . 接下来 n 行,每行为以下几种格式之一 : 0 x,把 x 加入 S 1 x,删除 S 中的一个 x…