当前位置:网站首页>Tree array and St table
Tree array and St table
2022-07-19 02:32:00 【HYYyyying】
Tree array and ST surface
dynamic : Tree array static state :ST surface
Tree array :cnt=x End of binary 0 The number of , Array d[x] Store 2^cnt Number .
Inquire about : such as 13,13 = 1101, Only one number is stored a[13], Now? , seek 13 The prefix of this position and :
( There are several 1 Divided into several parts ) Divided into three parts : ( Every time, the last one is erased 1,log Grade )
1101 d[13] 2^0
1100 d[12] 2^2
1000 d[8] 2^3
Single query complexity logn
modify : Modify the value of a node , You need to modify the value of the node that overrides him .
How to get the last end 1 Where is the location ?( principle , Complement or something )
Lowbit(int x){// Returns the... At the end of the binary 1 Where is the
return x & (-x);
}
summary : The query subtracts 1, Modify to add 1.
To solve : Interval query ( Prefixes and ideas ), Single point modification (lowbit Keep looking for his points to cover )
#include <stdio.h>
#include <string>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <math.h>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <vector>
using namespace std;
typedef long long ll;
#define pb push_back
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
/******** Single point modification , Interval query **********/
int lowbit(int x){
return x & (-x);
}
int ask(int x){
//[1, x], Satisfy prefix and
int res = 0;
while(x){
res += d[x];
}
x -= lowbit(x);
return res;
}
void add(int x, int v){
while(x <= n){
d[x] += v;
x += lowbit(x);
}
}
/********** Two dimensional tree array single point modification , Interval query ****************/
void update(int x, int y, int v){
for( ; x <= n; x += lowbit(x)){
for(int j = y; j <= n; j += lowbit(j)){
d[x][j] += v;
}
}
}
int getsum(int x, int y){
int res = 0;
for( ; x > 0; x -= lowbit(x)){
for(int j = y; j; j -= lowbit(j)){
res += d[x][j];
}
}
return res;
}
int main(){
return 0;
}
Single point query , Interval modification ( Difference thinking )
Maximum / Small value ( The segment tree is better , It's just that the constant is a little larger ,ST The watch is OK, too )
cf755D poj2352 bzoj1878 bzoj2743 bzoj1452
Two dimensional tree array
ST surface :RMQ problem
Line segment tree :O(n) Preprocessing Single inquiry O(logn) Space O(n)
ST surface :O(nlogn) Preprocessing Single inquiry O(1) Space O(nlogn)
d[i][j] An organization representing such a range : The left endpoint is i, The length is 2^j, signify , It governs [i,i + 2^j - 1]
CDOJ1591(ST surface )
边栏推荐
- How to do a good job of test case review
- GoReplay
- 树状数组与ST表
- Method of JMeter connecting to database
- 登录功能的测试点大全
- Buaaos-lab0 experimental report
- status 500 reading AftersaleService#getAftersaleList(Long)+com.sun.proxy.$Proxy214.getAftersaleList
- Unity导入fbx模型后,运行时物体的旋转和位置自动改变的问题解决方法
- sqlmap的使用
- STL -- map container
猜你喜欢

leetcode---每日一题

【Unity编辑器扩展】查找场景和资源内挂载某脚本的所有对象

innodb、Mysql结构、三种删除的区别
![【已解决】参考了本地mysql忘记密码后, [Server] --initialize specified but the data directory has files in it. Aborti](/img/a8/2daa2c0d834f1986c8421bf5138c7e.png)
【已解决】参考了本地mysql忘记密码后, [Server] --initialize specified but the data directory has files in it. Aborti

【Unity开发小技巧】Unity混音器Mixer控制全局音量

JS笔记1

Jmeter接口测试之响应断言

Interpretation of concurrent virtual users, RPS and TPS

项目性能优化实战:解决首页白屏问题,自定义 loading 动画优化首屏效果

STL -- List container (linked list)
随机推荐
VLAN和TRUNK口配置
怎么将软件的快捷方式添加到鼠标右键的列表中
How to do a good job of test case review
Jmeter响应时间测试组件&多接口并发
深入性能测试数据分析
Project Performance Optimization Practice: solve the white screen problem of the home page, customize the loading animation to optimize the first screen effect
使用JMeter测试基于WebSocket协议的服务
西加加
Nmon使用方法
简单的用例编写规范
网络一般知识(详)
[tools] Application of SQLite local database in unity3d
CTFHub----RCE
不会叭不会叭,昨天真有人没写出二进制枚举
2022 latest software testing tools
JS笔记1
STL -- vector container
最短路/次短路/K短路
[tools] unity2d character controller, which controls 2D players to move and jump in four directions and horizontal directions
树状数组与ST表