博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Dynamic Rankings
阅读量:5255 次
发布时间:2019-06-14

本文共 1986 字,大约阅读时间需要 6 分钟。

题目描述

The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the k-th smallest number of the given N numbers. They have developed a more powerful system such that for N numbers a[1], a[2], ..., a[N], you can ask it like: what is the k-th smallest number of a[i], a[i+1], ..., a[j]? (For some i<=j, 0<k<=j+1-i that you have given to it). More powerful, you can even change the value of some a[i], and continue to query, all the same.

Your task is to write a program for this computer, which
- Reads N numbers from the input (1 <= N <= 50,000)
- Processes M instructions of the input (1 <= M <= 10,000). These instructions include querying the k-th smallest number of a[i], a[i+1], ..., a[j] and change some a[i] to t.

给出一个长度为n的序列a,两种操作 
C x v:将第x个元素的值改成v 
Q l r k:查询区间[l,r]中第k大的元素 

输入

The first line of the input is a single number X (0 < X <= 4), the number of the test cases of the input. Then X blocks each represent a single test case.

The first line of each block contains two integers N and M, representing N numbers and M instruction. It is followed by N lines. The (i+1)-th line represents the number a[i]. Then M lines that is in the following format
Q i j k or
C i t
It represents to query the k-th number of a[i], a[i+1], ..., a[j] and change some a[i] to t, respectively. It is guaranteed that at any time of the operation. Any number a[i] is a non-negative integer that is less than 1,000,000,000.
There're NO breakline between two continuous test cases.

第一行为一个整数t表示用例组数,每组用例第一行为两个整数n和m分别表示序列长度和操作数,第二行n个整数表示序列a,之后m行每行一种操作 

(0< t<=4,1<=n<=50000,1<=m<=10000) 

输出

For each querying operation, output one integer to represent the result. (i.e. the k-th smallest number of a[i], a[i+1],..., a[j])

There're NO breakline between two continuous test cases.

对于每次查询,输出查询结果 

样例输入

2 5 3 3 2 1 4 7 Q 1 4 3 C 2 6 Q 2 5 3 5 3 3 2 1 4 7 Q 1 4 3 C 2 6 Q 2 5 3

样例输出

3 6 3 6

转载于:https://www.cnblogs.com/gshdyjz/p/7263498.html

你可能感兴趣的文章
STL sort函数的用法
查看>>
Mini-project # 4 - "Pong"___An Introduction to Interactive Programming in Python"RICE"
查看>>
Android常见的几种RuntimeException
查看>>
2018亚太CDN峰会开幕, 阿里云王海华解读云+端+AI的短视频最佳实践
查看>>
UVA-136Ugly numbers
查看>>
VS & Spyder & Jupyternotebook
查看>>
《Android深度探究HAL与驱动开发》学习笔记----第六章
查看>>
jprofiler 监听远程java项目
查看>>
线性SVM分类器实战
查看>>
GridView九宫格菜单实现方式
查看>>
mysql-day06
查看>>
vue2.0自学笔记
查看>>
Mina的客户端
查看>>
辣鸡(ljh)
查看>>
支持备案的域名后缀列表
查看>>
js 数组扁平化
查看>>
c# Enum获取name,value和description
查看>>
《C和指针》读书笔记 第5章-操作符和表达式
查看>>
mvc5 + ef6 + autofac搭建项目(repository+uow)(二)
查看>>
【转】C++ function、bind以及lamda表达式
查看>>