
树状数组
算球?
在校学生
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hdu 1556 Color the ball(线段树 or 树状数组 or 前缀和)
#include #include typedef struct node node;struct node{ int l,r,sum;};node ball[300000];int n;void BuildTree(int t, int l, int r){ ball[t].l = l; ball[t].r = r; ball[t].sum =原创 2016-06-19 21:40:33 · 709 阅读 · 0 评论 -
hdu 2642 Stars(二维树状数组)
二维BIT裸题#include <bits/stdc++.h>using namespace std;const int MAXN = 1e3+3;#define lowbit(x) (x&(-x))int f[MAXN][MAXN],a[MAXN][MAXN];void add(int x, int y, int val){ for(int i = x; i < MAXN; i +原创 2017-11-06 16:20:18 · 293 阅读 · 0 评论 -
hdu 1892 See you~(二维树状数组)
二维BIT裸题#include <bits/stdc++.h>using namespace std;const int MAXN = 1e3+3;#define lowbit(x) (x&(-x))int f[MAXN][MAXN],a[MAXN][MAXN];void add(int x, int y, int val){ for(int i = x; i < MAXN; i +=原创 2017-11-06 16:00:07 · 208 阅读 · 0 评论 -
HDU 3015 Disharmony Trees(树状数组)
看了一个树状数组的题,看了半天没看懂,很烦躁。就来看这题了。题目看懂了,思路有一点,就拿别人的代码来看了看。 http://www.cnblogs.com/GO-NO-1/p/3707853.html x坐标和高度离散化之后,分别按照x和h排个序,记录下来。然后高度从大到小排序,每次都保证当前高度是最小的。然后计算比当前x坐标小的那些树和当前树的F * S的和,再加上比当前树的x坐标大的那些树和原创 2017-10-25 22:03:53 · 269 阅读 · 0 评论 -
poj 2155 Matrix(二维树状数组)
每一点的值可以对应到前缀和,0和1对应奇偶性#include <stdio.h>#include <string.h>const int MAXN = 1010;int G[MAXN][MAXN];int n;int lowbit(int x){ return x&(-x);}void add(int x, int y, int c){ for(int i = x; i原创 2017-10-08 12:59:14 · 209 阅读 · 0 评论 -
51nod 1107 斜率小于0的连线数量(逆序数)
树状数组求逆序数 斜率小于0,就是在x从小到大的情况下,看y序列有多少逆序数。要对y离散化,注意x相等的情况。#include <bits/stdc++.h>using namespace std;const int MAXN = 50010;struct node{ int x,y;};node ns[MAXN];int bit[MAXN];bool cmp1(const n原创 2017-09-07 17:18:11 · 325 阅读 · 0 评论 -
hoj 2430 Counting the algorithms(树状数组,贪心)
记录下第一次出现的位置和 两次出现位置的距离差,按照距离差降序排个序,然后扫一遍。。 我看网上别人做法扫一遍,再扫一遍,完事了,效率比我这要高。。。没想到#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;struct node{ int si,dis;};const int原创 2017-08-11 15:14:37 · 271 阅读 · 0 评论 -
hoj 1867 经理的烦恼 (树状数组)
#include <stdio.h>#include <string.h>const int MAXN = 1e6+10;int num[MAXN];int cnt[MAXN];int C,N,M;bool isPrime(int num){ if(num <= 1) return false; for(int i = 2; i*i <= num; ++i)原创 2017-08-11 14:58:13 · 289 阅读 · 0 评论 -
hdu 1166 敌兵布阵(线段树 or 树状数组)
本来用c++写的,结果超时了,后来把输入输出都改成了c的,就ac了#include #include int num[50001];char command[10];typedef struct node node;struct node{ int l,r,person;};node numtree[200004];void BuildTree(int t,int原创 2016-06-15 22:19:57 · 386 阅读 · 0 评论 -
hdu 2227 Find the nondecreasing subsequences(树状数组+DP)
看到题目想到了逆序数。 首先是想:先离散化,对每个数字,统计在这之前有多少个数字比他小,再用BIT计算比他小的这些数字能组成多少序列,然后再加上一个单独的当前数字。试了下,对于升序数组是没问题,非升序的就不行,突然想到前边那些数字是有顺序的插进去的。。搜到:http://blog.youkuaiyun.com/u013582254/article/details/46334163 可以通过dp来更新啊。原创 2017-11-06 18:11:38 · 495 阅读 · 0 评论