
数据结构——树状数组
文章平均质量分 79
sdau_blue
念念不忘,必有回响。驰而不息,功不唐捐。
展开
-
japan(树状数组求逆序数)
http://poj.org/problem?id=3067DescriptionJapan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island with N cities on the East coast and M...原创 2017-08-16 16:38:28 · 263 阅读 · 0 评论 -
MASTER OF GCD(树状数组差分|线段树)
嗯。反正这道题当时忘记了树状数组差分。用的线段树。比赛时写这么长的线段树时间上多少有点吃亏。就是两个树,维护区间加1操作,然后分别查两棵树的最小值。树状数组差分:#include<bits/stdc++.h>using namespace std;const int maxn=100000+100;const int mod=998244353;...原创 2018-10-18 19:49:27 · 256 阅读 · 0 评论 -
hdu—5976—Aninteresting game(树状数组原理+特征)
Aninteresting gameTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 886 Accepted Submission(s): 341 Problem DescriptionLet’s play a gam...原创 2018-10-03 21:25:50 · 251 阅读 · 0 评论 -
Ryuji doesn't want to study(树状数组)
Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, each book has its knowledge a[i]a[i]a[i].Unfortunately, the longer he learns, the fewer he gets.Th...原创 2018-09-13 15:20:24 · 166 阅读 · 0 评论 -
POJ - 3468 A Simple Problem with Integers(树状数组(差分法)区间更新&区间查询)(小白萌新一看就懂)
转自:https://blog.youkuaiyun.com/kuronekonano/article/details/80146966这篇博客讲的十分详细,复习差分的时候看到的。小白萌新们一看就懂。You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operat...转载 2018-08-20 20:58:48 · 179 阅读 · 0 评论 -
D. Array Restoration(树状数组+思维)
Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)http://codeforces.com/contest/1023/problem/DD. Array Restorationtime limit per test1 secondmemory limit per test25...原创 2018-08-18 15:01:51 · 439 阅读 · 0 评论 -
codeforces-D. The Wu(状压+树状数组)
D. The Wutime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputChildan is making up a legendary story and trying to sell his forgery —...原创 2018-08-09 21:15:35 · 306 阅读 · 0 评论 -
Segment Game(树状数组)
暂时存下代码,细节有的没处理好。#include<bits/stdc++.h>using namespace std;const int maxn = 4e5+5;int p[maxn], a[maxn], b[maxn], num[maxn];int cnt, s[2][maxn];int bit(int x){ return x & (-x...原创 2018-08-05 21:23:38 · 1149 阅读 · 0 评论 -
PingPang
时隔好久,终于隐隐约约搞懂了树状数组。树状数组原来就不大会用,这道题也是似是而非。终于懂了就写写吧。题目大意: 一条大街上住着n个乒乓球爱好者,他们经常组织乒乓球比赛且每个人的能力值ai都不同.每次比赛需要2个比赛者和一个裁判,他们有一个奇怪的规定:当裁判的那个人必须住在这两个比赛者之间,且裁判的能力值也必须在这两个人之间.问一共有多少种比赛组织方式. 输入:首先是T(1<=T...原创 2018-04-20 12:19:38 · 774 阅读 · 0 评论 -
2017.8.24------二分+树状数组+逆逆
5 1 21 3 42 => 5 或者 51 3 30 1 1Problem RTime Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)Total Submission(s) : 26原创 2017-08-24 10:07:55 · 206 阅读 · 0 评论 -
2017.8.23-------树状数组---区间更新+区间查询
下面是转载的一篇文章: 【问题引入】对于区间修改、区间查询这样的简单问题,打一大堆线段树确实是不划算,今天来介绍一下区间查询+区间修改的树状数组【一些基础】树状数组的基本知识不再介绍,请自行百度我们假设sigma(r,i)表示r数组的前i项和,调用一次的复杂度是log2(i)设原数组是a[n],差分数组c[n],c[i]=a[i]-a[i-1],那么明显地a[i]翻译 2017-08-23 19:01:16 · 223 阅读 · 0 评论 -
三维树状数组-------
例题:Problem E Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)Total Submission(s) : 22 Accepted Submission(s) : 12Problem DescriptionGiven an N*N*N cube A原创 2017-08-25 19:47:42 · 440 阅读 · 0 评论 -
2017.8.20------二维树状数组的求和问题
这道题实在二维数组的求和问题Yifenfei is a romantic guy and he likes to count the stars in the sky.To make the problem easier,we considerate the sky is a two-dimension plane.Sometimes the star will be bright and原创 2017-08-20 21:41:11 · 348 阅读 · 0 评论 -
二维树状数组的求和问题
Problem BTime Limit : 5000/3000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 33 Accepted Submission(s) : 10Problem DescriptionNow I am leaving hust acm. In原创 2017-08-21 21:36:17 · 221 阅读 · 0 评论 -
2017.8.21-----二分!!!在树状数组中的巧妙运用
KiKi's K-NumberTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1314 Accepted Submission(s): 565Problem DescriptionFor the k-th nu原创 2017-08-21 12:20:44 · 1549 阅读 · 0 评论 -
2017.8.18------树状数组+离散+逆序
POJ2299 Ultra-QuickSort(树状数组+离散化或 归并排序求逆序)http://poj.org/problem?id=2299题意:给你一个n个整数组成的序列,每次只能交换相邻的两个元素,问你最少要进行多少次交换才能使得整个整数序列上升有序。分析:因为交换相邻的元素只会序列的逆序数减1,到最后的有序数列是没有逆序数的。所以我们只需要计算初始序列有多少逆序,转载 2017-08-18 10:19:43 · 256 阅读 · 0 评论 -
树状数组——————涂色(基础)
题意:N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a Input每个测试实例第一行为一个整数N,(N 当N = 0,输入结束。Output每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共被涂色的次数。分析: 本题用线段树可以很方便的解决。但是下面用树状数转载 2017-08-17 11:00:28 · 447 阅读 · 0 评论 -
出题人的手环(离散化树状数组求逆序+思维)
链接:https://ac.nowcoder.com/acm/contest/358/D来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述出题人的妹子送了出题人一个手环,这个手环上有 n 个珠子,每个珠子上有一个数。有一天,出题人和妹子分手了,想把这个手环从两...原创 2019-01-20 21:02:38 · 389 阅读 · 0 评论