AtCoder Grand Contest 058
翻译中…
Problem Statement
翻译中…
You are given a permutation $P=(P_1,P_2,\cdots,P_{2N})$ of $(1,2,\cdots,2N)$.
翻译中…
The following operation may be performed between $0$ and $N$ times (inclusive).
翻译中…
- Choose an integer
$x$($1 \leq x \leq 2N-1$). Swap the values of$P_x$and$P_{x+1}$.
翻译中…
Present a sequence of operations that make $P$ satisfy the following conditions.
翻译中…
$P_i<P_{i+1}$for each$i=1,3,5,\cdots,2N-1$;$P_i>P_{i+1}$for each$i=2,4,6,\cdots,2N-2$.
翻译中…
It can be proved that such a sequence of operations always exists.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 10^5$$(P_1,P_2,\cdots,P_{2N})$is a permutation of$(1,2,\cdots,{2N})$.- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
P_1 P_2 \cdots P_{2N}
翻译中…
Output
翻译中…
Print a desired sequence of operations in the following format:
翻译中…
K
x_1 x_2 \cdots x_K
翻译中…
Here, $K$ is the number of operations performed ($0 \leq K \leq N$), and $x_i$ is the value of $x$ chosen in the $i$-th operation ($1 \leq x_i \leq 2N-1$). If there are multiple solutions satisfying the condition, printing any of them will be accepted.
翻译中…
样例
Input #1
2
4 3 2 1
Output #1
2
1 3
These operations make $P=(3,4,1,2)$, which satisfies the conditions.
Input #2
1
1 2
Output #2
0
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。