1010 1100
3 After the first two steps, $a = [1, 3]$ and $b = [1, 2]$. There are $4$ possible scenarios after shuffling $a$ and $b$: * $a = [1, 3]$, $b = [1, 2]$. Initially, $A = 1010$. After swap($A_1$, $A_1$), $A = 1010$. After swap($A_3$, $A_2$), $A = 1100$. * $a = [1, 3]$, $b = [2, 1]$. Initially, $A = 1010$. After swap($A_1$, $A_2$), $A = 0110$. After swap($A_3$, $A_1$), $A = 1100$. * $a = [3, 1]$, $b = [1, 2]$. Initially, $A = 1010$. After swap($A_3$, $A_1$), $A = 1010$. After swap($A_1$, $A_2$), $A = 0110$. * $a = [3, 1]$, $b = [2, 1]$. Initially, $A = 1010$. After swap($A_3$, $A_2$), $A = 1100$. After swap($A_1$, $A_1$), $A = 1100$. Out of $4$ scenarios, $3$ of them result in $A = B$. Therefore, $P = 3$ / $4$, and $Z = 3$.
01001 01001
4 No swap ever changes $A$, so we'll always have $A = B$.
101010 010101
36 Every possible sequence of three swaps puts the $1$'s in $A$ into the right places.
1101011011110 0111101011101
932171449
{
"problem": {
"name": "Shuffle and Swap",
"description": {
"content": "You have two strings $A = A_1 A_2 ... A_n$ and $B = B_1 B_2 ... B_n$ of the same length consisting of $0$ and $1$. The number of $1$'s in $A$ and $B$ is equal. You've decided to transform $A$ using th",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "agc019_e"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You have two strings $A = A_1 A_2 ... A_n$ and $B = B_1 B_2 ... B_n$ of the same length consisting of $0$ and $1$. The number of $1$'s in $A$ and $B$ is equal.\nYou've decided to transform $A$ using th...",
"is_translate": false,
"language": "English"
}
]
}