树状数组
ordinarv
努力才是人生的常态
展开
-
牛客-区间 (interval)
链接:https://ac.nowcoder.com/acm/problem/16722 来源:牛客网 题目描述 Apojacsleam喜欢数组。 他现在有一个n个元素的数组a,而他要对a[L]-a[R]进行M次操作: 操作一:将a[L]-a[R]内的元素都加上P 操作二:将a[L]-a[R]内的元素都减去P 最后询问a[l]...原创 2018-12-20 16:04:42 · 263 阅读 · 0 评论 -
树状数组
树状数组是一个查询和修改复杂度都为log(n)的数据结构, 单点修改、区间询问 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAX_N=32005; const int maxn=15010; int n,tre[MAX_N]; ...原创 2018-07-21 20:46:52 · 90 阅读 · 0 评论 -
树状数组
POJ - 3067 题目大意:东西部各有许多城市,通过一些道路相连。求这些道路的交点个数。 代码 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; c...原创 2018-07-26 16:44:01 · 80 阅读 · 0 评论 -
2019牛客暑期多校训练营(第八场)D-Distance(三维BIT | 时间分治)
题意: 思路: 将曼哈顿距离去绝对值的8种情况分别用BIT维护。暴力讨论比较最小值。 BIT维护把每个点拆掉绝对值后的8种贡献。 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 3e5+5; const double eps = 1e-10; const in...原创 2019-08-12 15:56:13 · 278 阅读 · 0 评论 -
牛客练习赛4 A-Laptop(二维偏序)
传送门 题意:求 思路:很老的题目,一维排序,二维BIT,离散搞一下。 #include<bits/stdc++.h> using namespace std; const int maxn = 1e5+5; int n; struct unt{ int m,s; }bk[maxn]; bool cmp(unt a,unt b){ return a.m < b.m; ...原创 2019-09-02 21:21:18 · 238 阅读 · 0 评论