luogu#P5046. [Ynoi2019 模拟赛] Yuno loves sqrt technology I
[Ynoi2019 模拟赛] Yuno loves sqrt technology I
Background

Problem Description
You are given a permutation of length and queries. Each query asks for the number of inversion pairs in a subarray interval, and the queries must be answered online.
Input Format
The first line contains two integers .
The second line contains positive integers representing this permutation.
The next lines each contain two integers representing the query interval.
This problem is strictly online: for each query, the input numbers must be xor-ed with . For the first query, by default.
Output Format
Output lines. Each line contains one integer, the answer to the corresponding query.
4 1
1 4 2 3
2 4
2
Hint
.
We already have an online algorithm with time complexity below .
Source: By nzhtl1477.
Translated by ChatGPT 5