题意:给出数组A,定义f(l,r,x)为A[]的下标l到r之间,等于x的元素数.i和j符合f(1,i,a[i])>f(j,n,a[j]),求有多少对这样的(i,j). 解法:分别从左到右,由右到左预处理到某个下标为止有多少个数等于该下标,用map维护. 然后树状数组更新每个f(j,n,a[j]),预处理完毕,接下来,从左往右扫过去,每次从树状数组中删去a[i],因为i != j,i不能用作后面的统计,然后统计getsum(inc[a[i]]-1), (inc表示从左到右),即查询比此时的a[i]…
Codeforces Round #261 (Div. 2)   题意:给出数组A,定义f(l,r,x)为A[]的下标l到r之间,等于x的元素数.i和j符合f(1,i,a[i])>f(j,n,a[j]),求i和j的种类数. 题解:使用树状数组统计小于某数的元素数量. 我们可以先把f(1,i,a[i])和f(j,n,a[j])写出来,观察一下,例如样例1: n=7 A 1 2 1 1 2 2 1 R 4 3 3 2 2 1 1 L 1 1 2 3 2 3 4 其中A为给定的数组,Rj为f(j,n,…
D. Pashmak and Parmida's problem time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partn…
分析:a^b+2(a&b)=a+b  so->a^(-b)+2(a&(-b))=a-b 然后树状数组分类讨论即可 链接:http://www.ifrog.cc/acm/problem/1023 吐槽:这个题本来是mod(2^40),明显要用快速乘啊,但是用了以后狂T,不用反而过了,不懂出题人 #include <iostream> #include <algorithm> #include <cmath> #include <vector&g…
题意 2e5的数组,q个操作 1.将\(a[x]\)改为y 2.求下标l到r内所有的\(a[i]\)通过加法不能构成的最小的值 思路 通过二操作可以知道需要提取l到r内的值及其数量,而提取下标为l到r内的元素是一定要用主席树的 而用树状数组套上主席树即可实现修改操作 剩下需要解决的就是二操作: 首先只有有至少一个1,才能构成1 假设已经可以构成[1,x],设当前区间内值为[1,x+1]的和为sum 那显然我们就能构成[1,sum]了,如果sum==x,那么答案就是x+1 这个过程可以直接暴力,最…
题目链接: D. Pashmak and Parmida's problem time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her…
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak. There is a sequence a that consists of n…
题目链接 题意:给出数组A,定义f(l,r,x)为A[]的下标l到r之间,等于x的元素数.i和j符合f(1,i,a[i])>f(j,n,a[j]),求i和j的种类数. 我们可以用map预处理出 f(1, i, a[i]) 和 f(j, n, a[j]) ,记为s1[n], s2[n]. 这样就变成求满足 s1[i] > s[j], i < j 情况的数量了,你会发现跟求逆序对一样 分析: 做题的时候想到过逆序数,但是很快放弃了,还是理解不深刻吧,,,233. 看了这个博客以后才明白这些过…
Description Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak. There is a sequence a that co…
Pashmak and Parmida's problem Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 459D Description Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she…