410092: GYM103940 I Inversion Counting
Description
You have a sequence of $$$N$$$ integers $$$a_i$$$ with elements between $$$1$$$ and $$$K$$$, and you want to calculate the number of inversions. To make it more complicated you get $$$Q$$$ operations $$$i$$$, change all occurrences of $$$i$$$ to $$$i+1$$$, and vice versa.
Each operation changes the original sequence for the following operations.
note: is considered an inversion to a pair of indices ($$$i, j$$$), where $$$i < j$$$ and $$$a_i > a_j$$$.
InputThe first line contains three integers $$$N$$$, $$$K$$$, $$$Q$$$ ($$$1\le K\le N\le 100\,000$$$, $$$1\le Q\le 1\,000\,000$$$).
The next line contains $$$N$$$ integers $$$a_1, a_2, \dots, a_N$$$ ($$$1 \le a_i \le K$$$) specifying the sequence.
The following $$$Q$$$ lines each contain an integer $$$i$$$ ($$$1\le i \le K-1$$$), representing the operation of swapping $$$i$$$ elements with $$$i+1$$$, and vice versa.
OutputFor each $$$Q$$$ operation, print a single integer, the number of inversions as specified in the statement.
ExampleInput5 4 3 1 4 2 1 2 3 2 1Output
4 2 2