##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
You are given two permutations and .
In one operation, you choose two indices and with , then perform both of the following swaps simultaneously:
You may perform any number of operations, possibly zero.
For an array , define as the number of pairs such that and .
Your task is to find how many distinct values of can be obtained after performing the operations.
Output a single integer, the number of distinct possible values of .
With no operation, the arrays stay and , so the total is .
Swapping indices and makes the arrays and , so the total is .
Swapping indices and , then indices and , makes the arrays and , so the total is .
Swapping indices and makes the arrays and , so the total is .
Thus there are possible values.
With no operation, the arrays are and , and the total is .
Swapping indices and makes the arrays and , and the total is still .
Checking the other final arrangements gives the same total, so only value is possible.
With no operation, the arrays stay and , so the total is .
For example, after swapping indices and , then indices and , the arrays become and , so the total is .