题目链接: 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…
传送门:https://codeforces.com/contest/540/problem/E 题意: 有一段无限长的序列,有n次交换,每次将u位置的元素和v位置的元素交换,问n次交换后这个序列的逆序对个数为多少 题解: 因为值域范围为1e9,而n的范围只有1e5,所以我们肯定是不能直接交换的,对n次操作离散化,离散化后的数组最大为2e5,这里需要用到一些离散化的技巧. 将每次交换的u,v两个点放到map里面,键为pos,值为0 然后对于map映射,值就是离散化后的下标 离散化后我们应该做什么…
[链接] 我是链接,点我呀:) [题意] 定义两个函数 f和g f(i)表示a[1..i]中等于a[i]的数字的个数 g(i)表示a[i..n]中等于a[i]的数字的个数 让你求出来(i,j) 这里i<j 的二元组个数 且f(i)>g(j) [题解] 求出来两个数组g[N]和f[N]; (用map就行) 要算出(i< j)且f[i]>g[j]的个数 我们可以先把 g[1..n]全都加入到树状数组中. 然后顺序枚举i 遇到i就把g[i]从树状数组中删掉. 这样就只包括g[i+1..n…
题目链接:http://codeforces.com/contest/459/problem/D 题意:给出数组a,定义f(l,r,x)为a[]的下标l到r之间,等于x的元素数.i和j符合f(1,i,a[i])>f(j,n,a[j]),而且要求i<j,求i和j的种类数. 题解:先预处理一下设map be[a[i]]表示f(1,i,a[i])的值,然后在倒着来设af[a[j]]表示f(j,n,a[j])的值. 然后再用线段树更新一下长度为af[a[j]]的值然后再在树上查询小于be[a[j-1]…
题目链接 题意:给出数组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. 看了这个博客以后才明白这些过…
                                                                E. Infinite Inversions                                                                                          time limit per test 2 seconds                                            …
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…
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…
http://codeforces.com/contest/459/problem/D 题意:给你n个数,然后统计多少组(i,j)使得f(1,i,ai)>f(j,n,aj); 思路:先从左往右统计f(1,i,ai)记录在b[i],然后从右往左统计f(j,n,aj)记录在c[i],然后利用树状数组统计个数即可. #include <cstdio> #include <iostream> #include <cstring> #include <cmath>…
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…