题目描述
Snuke has permutations $(P_0,P_1,\cdots,P_{N-1})$ and $(Q_0,Q_1,\cdots,Q_{N-1})$ of $(0,1,\cdots,N-1)$.
Now, he will make new permutations $A$ and $B$ of $(0,1,\cdots,N-1)$, under the following conditions:
- For each $i$ ($0 \leq i \leq N-1$), $A_i$ should be $i$ or $P_i$.
- For each $i$ ($0 \leq i \leq N-1$), $B_i$ should be $i$ or $Q_i$.
Let us define the distance of permutations $A$ and $B$ as the number of indices $i$ such that $A_i \neq B_i$. Find the maximum possible distance of $A$ and $B$.
提示
- $1 \leq N \leq 100000$
- $0 \leq P_i \leq N-1$
- $P_0,P_1,\cdots,P_{N-1}$ are all different.
- $0 \leq Q_i \leq N-1$
- $Q_0,Q_1,\cdots,Q_{N-1}$ are all different.
- All values in input are integers.