随笔分类 - 树状数组and线段树
摘要:Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares...
阅读全文
摘要: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...
阅读全文
摘要:Time limit 8000 msMemory limit 65536 kB Yuanfang is puzzled with the question below: T...
阅读全文
摘要:A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the...
阅读全文
摘要:Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to
阅读全文
摘要:Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers,...
阅读全文
摘要:The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral p...
阅读全文
摘要:Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones. Your ta...
阅读全文
摘要:During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. General...
阅读全文
摘要:Time limit3000 msMemory limit32768 kBThere are a bunch of stones on the beach; Stone color is white or black. Little Sheep has a magic...
阅读全文
摘要:Time limit5000 msCase time limit2000 msMemory limit65536 kBFor the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up...
阅读全文
摘要:In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several cons...
阅读全文
摘要:Time limit5000 msCase time limit2000 msMemory limit131072 kBYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of ...
阅读全文
摘要:Time limit1000 msMemory limit100000 kBCorrupt governors always find ways to get dirty money. Paint something, then sell the worthless ...
阅读全文
摘要:首先是建树:const int MAXN = 1005;//定义 MAXM 为线段最大长度int Tree[4*MAXN];// Data数组为 main 函数中读入的内容,Tree数组为需要查询的数的信息(如和、最值等),树的空间大小为线段最大长度的四倍!四倍!四倍...
阅读全文
摘要:很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文...
阅读全文
摘要:In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swap...
阅读全文
摘要:C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二...
阅读全文
摘要:区间求和: tree[t]中储存的是[t,t-lowbit(t)+1]中每个数的和。#include #include #include #include using namespace std;#define MAXN 100int tree[MAXN];int N...
阅读全文
摘要:一个长度为M的正整数数组A,表示从左向右的地形高度。测试一种加农炮,炮弹平行于地面从左向右飞行,高度为H,如果某处地形的高度大于等于炮弹飞行的高度H(Ai >= H),炮弹会被挡住并落在i - 1处,则Ai−1 + 1。如果H 所有的Ai,这个炮弹也无效。现在给定N...
阅读全文