
树状数组
文章平均质量分 83
i-unique
擅长各种姿势划水
展开
-
POJ 2886 Who Gets the Most Candies?(反素数+数学推导+模拟+线段树||树状数组+二分)
N children are sitting in a circle to play a game.The children are numbered from 1 to N in clockwise order. Each of them has a card with a non-zero integer on it in his/her hand. The game starts from the K-th child, who tells all the others the integer on原创 2017-08-09 17:33:47 · 439 阅读 · 0 评论 -
模板总结
属于自己的模板。。。比赛防忘记赛前复习向原创 2017-07-24 10:25:30 · 1561 阅读 · 1 评论 -
HDU 1541 Stars(树状数组||线段树)
Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to原创 2017-07-10 19:21:49 · 451 阅读 · 0 评论 -
POJ 2481 Cows (线段树||树状数组)
Farmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good. Farmer John has N cows (we number the cows from 1 to N). Each of Farmer Joh原创 2017-07-12 11:23:24 · 508 阅读 · 0 评论 -
HDU 3874 Necklace (树状数组+离线操作)
Mery has a beautiful necklace. The necklace is made up of N magic balls. Each ball has a beautiful value. The balls with the same beautiful value look the same, so if two or more balls have the same beautiful value, we just count it once. We define the bea原创 2017-07-12 18:59:36 · 556 阅读 · 0 评论 -
POJ 3468 A Simple Problem with Integers (树状数组成段更新)
Let A1, A2, ... , AN be N elements. You need to deal with two kinds of operations. One type of operation is to add a given number to a few numbers in a given interval. The other is to query the value of some element.原创 2017-07-15 18:30:35 · 375 阅读 · 0 评论 -
POJ 2155 Matrix(二维树状数组+数组数组区间更新+单点查询)
Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can change the matrix in the following way. Given a rectangle whose upper-left corner is原创 2017-07-26 11:11:08 · 1525 阅读 · 0 评论 -
HDU 3333 Turing Tree(离线操作+线段树||树状数组)
After inventing Turing Tree, 3xian always felt boring when solving problems about intervals, because Turing Tree could easily have the solution. As well, wily 3xian made lots of new problems about intervals. So, today, this sick thing happens again... No原创 2017-07-27 09:45:12 · 481 阅读 · 0 评论 -
WUST 1954 小朋友排队(树状数组+求两次逆序对)
n 个小朋友站成一排。现在要把他们按身高从低到高的顺序排列,但是每次只能交换位置相邻的两个小朋友。 每个小朋友都有一个不高兴的程度。开始的时候,所有小朋友的不高兴程度都是0。 如果某个小朋友第一次被要求交换,则他的不高兴程度增加1,如果第二次要求他交换,则他的不高兴程度增加2(即不高兴程度为3),依次类推。当要求某个小朋友第k次交换时,他的不高兴程度增加k。 请问,要让所有小朋友按从低到高排队,他们的不高兴程度之和最小是多少。 如果有两个小朋友身高一样,则他们谁站在谁前面是没原创 2017-08-02 09:43:18 · 476 阅读 · 0 评论 -
HDU 2871 Memory Control(线段树区间合并+各种综合运用)【好题】
Memory units are numbered from 1 up to N. A sequence of memory units is called a memory block. The memory control system we consider now has four kinds of operations: 1. Reset Reset all memory units free. 2. New x Allocate a memory block consisted of原创 2017-08-02 20:36:34 · 578 阅读 · 0 评论 -
HDU 4417 Super Mario(线段树||树状数组+离线操作 之树状数组篇)
Mario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lover. We regard the road to the boss’s castle as a line (the length is n), on every原创 2017-08-04 15:13:48 · 411 阅读 · 0 评论 -
UVA 12086 Potentiometers(树状数组|| 线段树单点更新)
A potentiometer, or potmeter for short, is an electronic device with a variable electric resistance. It has two terminals and some kind of control mechanism (often a dial, a wheel or a slide) with which the resistance between the terminals can be adjusted原创 2017-08-08 19:06:15 · 348 阅读 · 0 评论 -
HDU 5493 Queue(树状数组+二分)
NN people numbered from 1 to NN are waiting in a bank for service. They all stand in a queue, but the queue never moves. It is lunch time now, so they decide to go out and have lunch first. When they get back, they don’t remember the exact order of the que原创 2017-09-12 21:32:43 · 370 阅读 · 0 评论