摘要:
二维树状数组板子, C[color] [x][y] #include <bits/stdc++.h> using namespace std ; const int N =403 ,M =2e5+4; #define int long long int A[N][N],c[101][N][N] ; 阅读全文
posted @ 2023-03-15 21:00
towboat
阅读(27)
评论(0)
推荐(0)
摘要:
多次询问子序列 [L,R] 包含了多少种不同的数? 我们使用离线+树状数组,和last[j]表示上一次出现j的位置,对于第p个的数j,我们add(last[j],-1),add(p,1),因为我们按照r排序,只用管最右边的一个,所以留下最右端的就可以,对于一个询问直接树状数组求区间和; #inclu 阅读全文
posted @ 2023-03-15 17:25
towboat
阅读(25)
评论(0)
推荐(0)
摘要:
求 某节点子树内比该节点的点权大的点的个数 值域上维护树状数组, #include <bits/stdc++.h> using namespace std ; const int N=1e5+2,M=N*2; int bin[N],len; int sum[N] ,n,ans[N],a[N]; in 阅读全文
posted @ 2023-03-15 12:55
towboat
阅读(31)
评论(0)
推荐(0)
浙公网安备 33010602011771号