![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树状数组
TzoZex
这个作者很懒,什么都没留下…
展开
-
楼兰图腾 树状数组求逆序和
题目链接注意:每次求逆序或正序和都需要初始化#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <iostream>#include <cmath>#include <vector>#i原创 2019-02-09 20:52:57 · 144 阅读 · 0 评论 -
简单题
题目链接思路类似于校门外的树那道题#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std;typedef long long ll;const int N=100010;int c1[N],c2[N];int...原创 2019-03-13 11:57:53 · 251 阅读 · 0 评论 -
清点人数
题目链接树状数组模板题#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std;typedef long long ll;const int N=500010;int c[N];int n,m;int low...原创 2019-03-13 11:31:28 · 796 阅读 · 0 评论 -
校门外的树
题目链接将区间修改转化为两个单点修改,则查询操作的结果为r左边的(个数减去l左边的)的个数,进而想到树状维护前缀和,具体思路是c1维护(的个数,c2维护)的个数,#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std...原创 2019-03-13 11:03:55 · 125 阅读 · 0 评论 -
数星星 Stars
题目链接y从小到大排序,y相同x从小到大排序,转化为当前星星i之前,x小于等于的i的星星个数,即为这个星星的级数(正序对问题)#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std;typedef long lon...原创 2019-03-12 22:15:01 · 533 阅读 · 0 评论 -
楼兰图腾
题目链接树状数组求逆序对#include<iostream>#include<algorithm>#include<cstring>using namespace std;typedef long long ll;const int N=200010;int n;int a[N],r[N],l[N],c[N];int ask(int x){...原创 2019-03-12 21:18:43 · 444 阅读 · 0 评论 -
校门外的树
题目链接#include <cstring>#include <cstdlib>#include <algorithm>#include <iostream>#include <cmath>#include <vector>#include <map>#include <stack&a原创 2019-03-04 14:50:13 · 90 阅读 · 0 评论 -
数星星 Stars
题目链接直接二维树状数组会超内存,利用贪心排序降维(题目数据已经有序)#include <cstring>#include <cstdlib>#include <algorithm>#include <iostream>#include <cmath>#include <vector>#include <...原创 2019-03-04 14:34:06 · 251 阅读 · 0 评论 -
小朋友排队
题目链接1.利用等差数列转化为求逆序对和正序对2.树状数组优化因为ans的输出问题WA了好多次。。#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;typedef long long ll;const ...原创 2019-03-13 23:26:10 · 470 阅读 · 0 评论