树状数组
文章平均质量分 73
Fushicho_XF
对知识无比的向往,渴望打开新世界的大门~
展开
-
牛客网暑期ACM多校训练营(第五场)F.take (逆元+树状数组)
题目链接时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Kanade has n boxes , the i-th box has p[i] probability to have an diamond of d[i] size.At the beginning , Kanad...原创 2018-08-05 13:33:18 · 130 阅读 · 0 评论 -
牛客网暑期ACM多校训练营(第一场)J.Different Integers (树状数组+思维)
题目链接时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述Given a sequence of integers a1, a2, ..., an and q pairs of integers (l1, r1), (l2, r2), ..., (lq, rq), find cou...原创 2018-07-20 23:26:41 · 512 阅读 · 0 评论 -
牛客网暑期ACM多校训练营(第二场)J.farm (随机数+二维树状数组)
题目链接时间限制:C/C++ 4秒,其他语言8秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述White Rabbit has a rectangular farmland of n*m. In each of the grid there is a kind of plant. The plant in the j-...原创 2018-07-22 00:41:12 · 848 阅读 · 0 评论 -
二维树状数组及其"变式" (树状数组)
二维树状数组涉及到两种基本操作,修改矩阵中的一个点,查询子矩阵的和首先是修改点的操作:void update(int x,int y,int z){ for(int i=x;i<=n;i+=lowbit(i)) for(int j=y;j<=m;j+=lowbit(j)) c[i][j]+=z;}然后是查询子矩阵的和,这里查询的是从左上...转载 2018-07-22 00:20:08 · 334 阅读 · 1 评论 -
POJ - 2352 Stars (树状数组)
题目链接题意:给出一个n,然后n行,每行给出一个星星的坐标(x,y),若一个星星A坐标为(x1,y1),另一个星星B坐标为(x2,y2),且有x1>=x2&&y1>=y2,则星星A的等级+1,输出0~n-1等级的星星的数量.题解:我们只要先对y排序(从小到大,当y同时对x排序),每次添加一个点的x坐标时,对数组tre[x+1]~tre[maxn]进行+1操作(加...原创 2018-08-19 13:46:20 · 204 阅读 · 0 评论