#P10028. [Ynoi2000] pri
[Ynoi2000] pri
Problem Description
Given a permutation of .
There are operations. In each operation, an integer is given. First, perform a modification: reverse into . Then query how many distinct pairs satisfy and .
Input Format
The first line contains two integers .
The second line contains integers representing in order.
The next lines each contain one integer , representing an operation.
Output Format
Output lines. Each line contains one integer, representing the answer to the query for each operation in order.
6 5
5 4 2 3 1 6
3
5
6
3
6
3
6
4
2
10
Hint
Idea: ccz181078, Solution: ccz181078, Code: ccz181078, Data: ccz181078.
All values are integers.
Constraints: for of the testdata, , , , .
Translated by ChatGPT 5