4 3 1 2 1 2 1 3 5
2 3 2 4 1 2 $f(1, 2) = (2, 1, 1, 2), f(1, 3) = (1, 2, 1, 2), f(1, 4) = (2, 2, 1, 1), f(2, 3) = (1, 1, 2, 2), f(2, 4) = (1, 2, 1, 2), f(3, 4) = (1, 2, 2, 1)$. The sequence $B$ obtained by sorting these six sequences in lexicographical order is $B=((1, 1, 2, 2), (1, 2, 1, 2), (1, 2, 1, 2), (1, 2, 2, 1), (2, 1, 1, 2), (2, 2, 1, 1))$. * For the $1$\-st query, the only $(l,r)$ such that $B_1=(1,1,2,2)=f(l,r)$ is $(l,r)=(2,3)$. * For the $2$\-nd query, $(l,r)$ such that $B_3=(1,2,1,2)=f(l,r)$ are $(l,r)=(1,3),(2,4)$. In this case, either one will be considered correct. * For the $3$\-rd query, the only $(l,r)$ such that $B_5=(2,1,1,2)=f(l,r)$ is $(l,r)=(1,2)$.
10 10 1 1 2 7 6 3 5 7 3 3 21 36 9 17 13 24 7 45 33 1
6 8 2 4 5 7 9 10 8 9 3 9 5 9 1 8 2 10 4 10
{
"problem": {
"name": "One Time Swap 2",
"description": {
"content": "You are given an integer sequence $A=(A_1,A_2,\\ldots,A_N)$ of length $N$. For a pair of integers $(l, r) \\ (1\\leq l\\lt r\\leq N)$, let $f(l,r)$ be the integer sequence obtained by swapping the $l$\\-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": "abc431_g"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given an integer sequence $A=(A_1,A_2,\\ldots,A_N)$ of length $N$.\nFor a pair of integers $(l, r) \\ (1\\leq l\\lt r\\leq N)$, let $f(l,r)$ be the integer sequence obtained by swapping the $l$\\-th ...",
"is_translate": false,
"language": "English"
}
]
}