墨墨购买了一套N支彩色画笔(其中有些颜色可能相同),摆成一排,你需要回答墨墨的提问.墨墨会像你发布如下指令: 1. Q L R代表询问你从第L支画笔到第R支画笔中共有几种不同颜色的画笔. 2. R P Col 把第P支画笔替换为颜色Col.为了满足墨墨的要求,你知道你需要干什么了吗? Input 第1行两个整数N,M,分别代表初始画笔的数量以及墨墨会做的事情的个数.第2行N个整数,分别代表初始画笔排中第i支画笔的颜色.第3行到第2+M行,每行分别代表墨墨会做的一件事情,格式见题干部分. Outp
题意:对于两个区间,[si,ei] 和 [sj,ej],若 si <= sj and ei >= ej and ei - si > ej - sj 则说明区间 [si,ei] 比 [sj,ej] 强.对于每个区间,求出比它强的区间的个数. 解题思路:先将每个区间按 e 降序排列,在按 s 升序排列.则对于每个区间而言,比它强的区间的区间一定位于它的前面. 利用数状数组求每个区间[si,ei]前面 满足条件的区间[sj,ej]个数(条件:ej<=ei),再减去前面的和它相同的区间的个
Problem Description One day Sophia finds a very big square. There are n trees in the square. They are all so tall. Sophia is very interesting in them.She finds that trees maybe disharmony and the Disharmony Value between two trees is associated with
You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval. Input The firs
Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18543 Accepted Submission(s): 11246 Problem Description The inversion number of a given number sequence a1, a2, ..., a
Ping pong Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2611 Accepted Submission(s): 973 Problem Description N(3<=N<=20000) ping pong players live along a west-east street(consider the str
Ultra-QuickSort Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 70674 Accepted: 26538 Description In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swappin
Given a list of N integers A1, A2, A3,...AN, there's a famous problem to count the number of inversions in it. An inversion is defined as a pair of indices i < j such that Ai > Aj. Now we have a new challenging problem. You are supposed to count the
You are given an N × N matrix. At the beginning every element is 0. Write a program supporting 2 operations: 1. Add x y value: Add value to the element Axy. (Subscripts starts from 0 2. Sum x1 y1 x2 y2: Return the sum of every element Axy for x1 ≤ x
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5869 Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) 问题描述 This is a simple problem. The teacher gives Bob a list of problems about GCD (Great
敌兵布阵 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 99913 Accepted Submission(s): 42300 Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务
题意: 给N个数.a[1]....a[N]. M种操作: S X Y:令a[X]=Y Q L R D P:查询a[L]...a[R]中满足第D位上数字为P的数的个数 数据范围: 1<=T<= 501<=N, M<=1000000<=a[i]<=$2^{31}$ - 11<=X<=N0<=Y<=$2^{31}$ - 11<=L<=R<=N1<=D<=100<=P<=9 思路: 直接开tree[maxn][1
Cube Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 1166 Accepted Submission(s): 580 Problem Description Given an N*N*N cube A, whose elements are either 0 or 1. A[i, j, k] means the number
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5397 Accepted Submission(s): 2882 Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球