6 1 2 3 3 1 1
360 For example, we can obtain the permutation $A = (1,2,4,3,5,6)$ through the following steps. * Perform the operation with $i=5$. Replace $A_5$ with $3$ and $A_6$ with $6$. Now, $A = (1,2,3,3,3,6)$. * Perform the operation with $i=3$. Replace $A_3$ with $4$ and $A_5$ with $5$. Now, $A = (1,2,4,3,5,6)$. There are $360$ possible resulting sequences $A$ that are permutations of $(1, \ldots, 6)$.
5 3 1 3 4 1
0 There are no possible resulting sequences $A$ that are permutations of $(1, \ldots, 5)$.
10 1 1 1 8 8 8 7 7 7 10
604800
{
"problem": {
"name": "Replace Triplets",
"description": {
"content": "You are given a sequence $A = (A_1, \\ldots, A_N)$ of length $N$. Here, $N$ is an integer not less than $3$. You can perform the following operation any number of times (zero or more). * Choose an i",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc187_e"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given a sequence $A = (A_1, \\ldots, A_N)$ of length $N$. Here, $N$ is an integer not less than $3$.\nYou can perform the following operation any number of times (zero or more).\n\n* Choose an i...",
"is_translate": false,
"language": "English"
}
]
}