#P10633. BZOJ2989 数列/BZOJ4170 极光
BZOJ2989 数列/BZOJ4170 极光
Problem Description
Given a sequence of positive integers of length , the value between two positions is the sum of their position difference and value difference: .
You must support two types of operations (all are positive integers):
Modify x k, meaning modify the value of the -th number to ;Query x k, meaning ask how many satisfy .
The query must consider not only the current sequence, but also any historical version. That is, count the number of pairs where any value that has ever appeared at any position and the current has value . (If a position is modified to the same value multiple times, count it multiple times.)
Input Format
The first line contains two integers , representing the sequence length and the number of operations.
The second line contains positive integers, representing the initial sequence.
Lines to each contain one operation.
Output Format
For each query operation, output one non-negative integer as the answer.
3 5
2 4 3
Query 2 2
Modify 1 3
Query 2 2
Modify 1 2
Query 1 1
2
3
3
Hint
For all testdata, it is guaranteed that , the number of modify operations , the number of queries , and the maximum value among all historical versions of .
Translated by ChatGPT 5