题意:在二维坐标轴上给你一些点,求出所有由三个点构成的v和∧图案的个数. 题解:因为给出的点是按横坐标的顺序给出的,所以我们可以先遍历然后求出某个点左边比它高和低的点的个数(这个过程简直和用树状数组求逆序对的操作一模一样好不好!),用\(grt[i]\)记录第\(i\)个点左边比它大的数,\(low[i]\)表示比它小的数,然后我们再对树状数组清空,反着求一下每个点右边的情况,这次不用再记录了,直接求贡献给答案即可. 代码: #define int long long int n; int a[…
题目:https://www.acwing.com/problem/content/description/243/ 题意:给你n个点,问你 V 和 ^的图腾有多少个 思路:比如V 其实就是找当前点左边比自己大的点的个数,右边比自己大的个数,然后乘法原理组合一下,^也是一样的道理 #include<bits/stdc++.h> #define maxn 200005 #define mod 1000000007 using namespace std; typedef long long l…
题意:区间更新,区间询问. 题解;对于区间更新,我们还是用差分数组\(b_i\)来更新,区间询问时,我们的答案是:\(\sum_{i=l}^{r}\sum_{j=1}^{i}b_j\), 所以,我们搞两个树状数组维护\(b_i\)和\(i*b_i\)即可. 代码: #define int long long int n,m; int a[N]; int c1[N],c2[N]; int lowbit(int x){ return x&(-x); } void updata1(int i,int…
题目链接: C. Subsequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is…
E. e-Government time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output The best programmers of Embezzland compete to develop a part of the project called "e-Government" — the system of automa…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2227 Find the nondecreasing subsequences Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) …
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1394 Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10…
题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4923 problem description Last night, Kingdom of Light was attacked by Kingdom of Dark! The queen of Kingdom of Light, Queen Ar, was ca…
The k-th Largest Group Time Limit: 2000MS Memory Limit: 131072K Total Submissions: 8807 Accepted: 2875 Description Newman likes playing with cats. He possesses lots of cats in his home. Because the number of cats is really huge, Newman wants to g…