
树状数组
文章平均质量分 71
Mr_Treeeee
这个作者很懒,什么都没留下…
展开
-
HDU 1556 Color the ball(线段树|树状数组)
Color the ballTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 21795 Accepted Submission(s): 10552Problem DescriptionN个气球排成一排,原创 2017-07-26 21:48:46 · 482 阅读 · 0 评论 -
Codeforces Round #510 (Div. 2) - D. Petya and Array (树状数组+离散化)
http://codeforces.com/contest/1042/problem/D题意:给你n个数,询问你区间和小于t的个数。POINT:即sum[r]-sum[l-1]<t的(r,l)的对数(r>l)。可以用逆序对的做法。把sum数组离散化之后。每次sum[i]去找>sum[i]-t的前缀和的个数。 别忘记了sum[0]=0. ...原创 2018-09-27 22:03:17 · 247 阅读 · 0 评论 -
2018"百度之星"程序设计大赛 - 资格赛 - 序列计数 (树状数组)
http://acm.hdu.edu.cn/showproblem.php?pid=6348开一个C数组。当要找长度为x的答案时,记录之前遍历x-1长度的a[i]的答案。然后一个个加入树状数组更新即可。因为随机:最长上升子序列的长度期望是 √n所以可以暴力的来。期望效率是 √n*n*log(n) #include <stdio.h...原创 2018-08-07 22:47:28 · 346 阅读 · 0 评论 -
牛客网暑期ACM多校训练营(第五场) - F take (树状数组)
https://www.nowcoder.com/acm/contest/143/F 题意:一个人依次按顺序打开1-n号宝箱。若宝箱里有一颗比他手上还大的钻石,他会换走。给你宝箱i里Di大的钻石出现的几率是Pi,问你交换的期望。 POINT:总期望就等于每个宝箱被交换的期望和。第i个宝箱被交换的概率就是 前面1到i-1个宝箱都没有出现【比它大的钻石】的概率。你可...原创 2018-08-03 22:09:29 · 235 阅读 · 0 评论 -
牛客网暑期ACM多校训练营(第一场) - J Different Integers (树状数组)
题目题目描述 Given a sequence of integers a1, a2, ..., an and q pairs of integers (l1, r1), (l2, r2), ..., (lq, rq), find count(l1, r1), count(l2, r2), ..., count(lq, rq) where count(i, j) is the number...原创 2018-07-19 19:35:20 · 549 阅读 · 0 评论 -
AtCoder Regular Contest 097 - E - Sorted and Sorted (逆序对)
点击打开链接题意:给你黑白两种1-n编号的球。让你交换相邻的球,让黑i在黑i+1的上面。百i在白i+1的上面。POINT:dp[x][y]代表排好了白1-x和黑1-y 编号的球。dp[x][y]从dp[x-1][y]或dp[x][y-1]推出来。用树状数组算出逆序对。#include<iostream>#include<stdio.h>#include<algor...原创 2018-05-30 21:50:29 · 437 阅读 · 0 评论 -
HDU 3450 - Counting Sequences (树状数组+离散化)
Counting SequencesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/65536 K (Java/Others)Total Submission(s): 2687 Accepted Submission(s): 955Problem DescriptionFor a se原创 2018-02-05 14:19:24 · 275 阅读 · 0 评论 -
Codeforces Round #451 (Div. 2) - D. Alarm Clock(贪心)
D. Alarm Clocktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEvery evening Vitalya sets n alarm clocks to原创 2017-12-18 22:34:32 · 502 阅读 · 0 评论 -
Codeforces Round #452 (Div. 2) - F. Letters Removing(树状数组+set)
F. Letters Removingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya has a string of lengthnconsisting of small and lar...原创 2019-03-28 16:42:32 · 648 阅读 · 0 评论 -
ZUFE 2017院赛 - Problem M: 图样图森破(树状数组)
由最后一句话可知,这个图为一个环。那么用树状数组保存每一条边的值,然后每一次询问找u到v的总值就行,然后和取反比较(即总长度减去这个值,就是另一个方向的)。输出比较大的。更改值也容易。先处理一下每个点的位置,毕竟1 2 3 4 不一定连接在一起。我的算法对n=1,n=2会有问题,所以特判一下。 当时时间不够查代码了,说到底还是菜。#include #include原创 2017-12-10 22:45:17 · 515 阅读 · 0 评论 -
HDU 4911 - Inversion(树状数组||归并排序)
InversionTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 5250 Accepted Submission(s): 1845Problem Descriptionbobo has a seq原创 2017-11-21 22:32:38 · 401 阅读 · 0 评论 -
2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 - G Query on a string (KMP+树状数组)
You have two strings SS and TT in all capitals.Now an efficient program is required to maintain a operation and support a query.The operation C i chC i ch with given integer ii and capital l原创 2017-09-17 23:34:03 · 482 阅读 · 0 评论 -
HDU 3584 Cube(三维树状数组)
CubeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 2278 Accepted Submission(s): 1163Problem DescriptionGiven an N*N*N cube原创 2017-08-06 22:25:11 · 389 阅读 · 0 评论 -
HDU 4000 Fruit Ninja(树状数组)
Fruit NinjaTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2529 Accepted Submission(s): 988Problem DescriptionRecently, dobby原创 2017-08-06 22:22:03 · 314 阅读 · 0 评论 -
HDU 2852 KiKi's K-Number (树状数组+二分)
KiKi's K-NumberTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4144 Accepted Submission(s): 1866Problem DescriptionFor the k-原创 2017-08-06 22:13:09 · 367 阅读 · 0 评论 -
HDU 1892 See you~(二维树状数组 单点更新)
See you~Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 5646 Accepted Submission(s): 1795Problem DescriptionNow I am leaving原创 2017-08-06 22:10:46 · 291 阅读 · 0 评论 -
POJ 2155 Matrix(二维树状数组)
MatrixTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 28817 Accepted: 10507DescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[i, j]原创 2017-08-06 16:43:52 · 367 阅读 · 0 评论 -
HDU 5862 Counting Intersections(树状数组+扫描线+离散化)
Counting IntersectionsTime Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1296 Accepted Submission(s): 407Problem DescriptionGiv原创 2017-07-26 22:12:53 · 433 阅读 · 0 评论 -
Educational Codeforces Round 54 - E. Vasya and a Tree (树+树状数组)
http://codeforces.com/contest/1076/problem/E 题意:给你一棵n个点的树,以1为根。一开始n个点的权值为0,每个边的边长为1.给你m个操作,每次给v,d,x。把所有祖先是v的,且距离v不超过d的点的权值都加上x。 POINT:就是一个树上的搜索,加上树状数组(x这个点的答案是他的深度到n这些权值的和)它要存,当前状态下,操作...原创 2018-11-13 22:09:47 · 337 阅读 · 0 评论