#P4168. [Violet] 蒲公英
[Violet] 蒲公英
Description
There are many dandelions planted along a country path, and our problem is about these dandelions.
To simplify, we treat all the dandelions as a sequence of length , , where is a positive integer representing the type ID of the -th dandelion.
For each query on an interval , you need to report which type appears most frequently in the interval. If several types are tied, output the smallest type ID among them.
Note: your algorithm must be online.
Input Format
The first line contains two integers, representing the number of dandelions and the number of queries .
The second line contains integers. The -th integer is the type of the -th dandelion.
Then follow lines. Each line contains two integers , representing one query. The input is encrypted; the decryption is as follows:
Let the previous query’s result be (if this is the first query, then ), and set $l=((l_0+x-1)\bmod n) + 1, r=((r_0+x-1) \bmod n) + 1$. If , swap .
The final query interval is the computed .
Output Format
For each query, output one integer on its own line representing the answer.
6 3
1 2 3 2 1 2
1 5
3 6
1 5
1
2
1
Hint
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号