
树状数组
UCAS王小二
不念过去,不畏未来...
展开
-
hdu 1166 敌兵布阵【入门线段树 & 树状数组】
敌兵布阵Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 93502 Accepted Submission(s): 39459Problem DescriptionC国的死对头A国这段时间正在进行军事演原创 2017-07-26 09:01:42 · 311 阅读 · 0 评论 -
zzuli 1731: 矩阵【二维树状数组】
zzuli 1731: 矩阵; 分析:二维树状数组入门题,由于修改次数比较少,暴力+一定技巧 也可以解;#include <bits/stdc++.h>using namespace std;typedef long long LL;const int MAXN = 1000 + 10;int tree[MAXN][MAXN], arr[MAXN][MAXN]; ...原创 2018-04-27 17:55:42 · 203 阅读 · 0 评论 -
FZU 2216 The Longest Straight【二分||二分+树状数组+优化常数】
ZB is playing a card game where the goal is to make straights. Each card in the deck has a number between 1 and M(including 1 and M). A straight is a sequence of cards with consecutive values. Values ...原创 2018-04-25 09:30:01 · 190 阅读 · 0 评论 -
HDU 2838 Cow Sorting【树状数组+逆序数】
Sherlock’s N (1 ≤ N ≤ 100,000) cows are lined up to be milked in the evening. Each cow has a unique “grumpiness” level in the range 1…100,000. Since grumpy cows are more likely to damage Sherlock’s mi...原创 2018-04-26 21:48:47 · 215 阅读 · 0 评论 -
hdu 2689 Sort it【逆序数+树状数组】
You want to processe a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted in ascending order. Then how many times it need. For example, 1 2 3 5 4...原创 2018-04-24 18:16:58 · 241 阅读 · 0 评论 -
hdu 3887 Counting Offspring【DFS序+树状数组】
Problem Description You are given a tree, it’s root is p, and the node is numbered from 1 to n. Now define f(i) as the number of nodes whose number is less than i in all the succeeding nodes of nod原创 2018-02-01 17:48:13 · 260 阅读 · 0 评论 -
nyoj 117 求逆序数【树状数组】
求逆序数 时间限制:2000 ms | 内存限制:65535 KB 难度:5 描述 在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序的总数就称为这个排列的逆序数。现在,给你一个N个元素的序列,请你判断出它的逆序数是多少。比如 1 3 2 的逆序数就是1。输入 第一行输入一个整数T表示测试数据的组数(1<=T<=5) 每组原创 2017-08-03 09:17:30 · 352 阅读 · 0 评论 -
51 nod 1019 逆序数【归并排序||树状数组】
1019 逆序数基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序的总数就称为这个排列的逆序数。如2 4 3 1中,2 1,4 3,4 1,3 1是逆序,逆序数是4。给出一个整数序列,求该序列的逆序数。Input第1行:N,N为序列的长度(n <...原创 2017-07-20 21:01:22 · 470 阅读 · 0 评论 -
hdu1556 Color the ball【树状数组 || 线段树 || 技巧*区间修改】
思路: 新生赛做过类似的题目,对【l,r】区间修改值,只需要l端加一,r+1端减一就好,最后正序相加输出;#include<cstdio>#include<cstring>#define max_n 100010int a[max_n];int main(){ int n,l,r; while(scanf("%d",&n) && n) { mems原创 2017-08-02 13:47:17 · 2379 阅读 · 0 评论 -
HDU 2642 Stars【二维树状数组】
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 sometimes the ...原创 2018-04-27 17:59:44 · 240 阅读 · 0 评论