![](https://img-blog.csdnimg.cn/20190927151053287.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
树状数组
树状数组
七九河开
这个作者很懒,什么都没留下…
展开
-
掌握树状数组~彻底入门
原文链接 https://www.cnblogs.com/acgoto/p/8583952.html 模板 int lowbit(int i) { return i & -i;//或者是return i-(i&(i-1));表示求数组下标二进制的非0最低位所表示的值 } void update(int i,int val)//单点更新 { while(i<...转载 2018-12-11 14:18:17 · 126 阅读 · 0 评论 -
K-inversions URAL - 1523 (DP+树状数组)
链接 https://cn.vjudge.net/problem/URAL-1523 题意 给你一个1-n的序列 问长度为K的序列有多少种 思路 首先想到DP 递推式 dp[i][j] = ∑dp[x][j-1] ( 1<x<i,a[x] > a[i]) 写成数组 即求当前(j-n)项和 #include <bits/stdc++.h> using n...原创 2018-12-11 14:24:00 · 148 阅读 · 1 评论 -
逆序对
二分 #include<cstdio> #include<iostream> #include<cstring> using namespace std; const int N=100010; int a[N],b[N],n,ans=0; void merge(int l,int r) { if (l==r) return; in...原创 2018-12-07 19:58:42 · 207 阅读 · 0 评论 -
Intersecting Rectangles Kattis - intersectingrectangles (扫描线)
题目 https://cn.vjudge.net/problem/Kattis-pieceofcake 题意 给你n个矩形 问是否存在相交 思路 扫描线,从左向右扫,树状数组维护竖线有哪些横坐标,左边竖线先查询在添加,右边竖线先减去在查询 代码 #include <bits/stdc++.h> using namespace std; typedef long lon...原创 2019-04-08 16:05:09 · 433 阅读 · 1 评论