#P2617. Dynamic Rankings
Dynamic Rankings
Description
Given a sequence of numbers , you need to support two operations:
Q l r kqueries the -th smallest number among indices in the interval .C x ysets to .
Input Format
The first line contains two positive integers , the sequence length and the number of operations. The second line contains integers, representing . The next lines each describe an operation, which is one of the two types above.
Output Format
For each query, output one integer on a separate line representing the answer.
5 3
3 2 1 4 7
Q 1 4 3
C 2 6
Q 2 5 3
3
6
Hint
Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , , , .
Pay attention to constant-factor optimizations, but straightforward implementations of overall binary search on values ("整体二分") and tree-of-trees ("树套树") can both pass in about 1000 ms per test point.
Source: bzoj1901.
This problem uses custom Luogu testdata, generated with CYaRon in minutes.
Translated by ChatGPT 5
京公网安备 11011102002149号