#P6611. [Code+#7] 六元环
[Code+#7] 六元环
Description
qwqwq.
Given a sequence , where , and are given in the input.
For , define and to be adjacent, and define and to be adjacent. If and are adjacent, then and are also adjacent.
If , and is adjacent to , is adjacent to , and all are pairwise distinct, then the set is called a hexagonal cycle (that is, when judging whether two hexagonal cycles are the same, the order of is not considered).
There are modification operations. Each operation gives , and changes to . After each modification, you need to output the number of hexagonal cycles.
All values mentioned above are integers, and , , .
Input Format
The first line contains an integer .
The second line contains integers representing .
The third line contains an integer . The next lines each contain two integers , representing one modification operation.
Output Format
Output lines, each containing one integer, representing the number of hexagonal cycles after each modification.
6
1 2 5 4 3 6
4
1 8
3 6
5 10
2 7
3
0
1
1
Hint
| Subtask | Score | Constraints |
|---|---|---|
| for each operation, | ||
| for each operation, | ||
Translated by ChatGPT 5
京公网安备 11011102002149号