3 1 2 2 3
3 2 1
This permutation has a similarity of $1$, which can be computed as follows.
* For $x=(1)$, we have $y=(P_1)=(3)$. The length of a longest common subsequence of $x$ and $y$ is $0$.
* For $x=(2)$, we have $y=(P_2)=(2)$. The length of a longest common subsequence of $x$ and $y$ is $1$.
* For $x=(3)$, we have $y=(P_2)=(1)$. The length of a longest common subsequence of $x$ and $y$ is $0$.
* For $x=(1,2)$, we have $y=(P_1,P_2)=(3,2)$. The length of a longest common subsequence of $x$ and $y$ is $1$. The same goes for $x=(2,1)$, the reversal of $(1,2)$.
* For $x=(2,3)$, we have $y=(P_2,P_3)=(2,1)$. The length of a longest common subsequence of $x$ and $y$ is $1$. The same goes for $x=(3,2)$, the reversal of $(2,3)$.
* For $x=(1,2,3)$, we have $y=(P_1,P_2,P_3)=(3,2,1)$. The length of a longest common subsequence of $x$ and $y$ is $1$. The same goes for $x=(3,2,1)$, the reversal of $(1,2,3)$.
We can prove that no permutation has a similarity of $0$ or less, so this permutation is a valid answer.4 2 1 2 3 2 4
3 4 1 2 If multiple permutations have the minimum similarity, you may print any of them. For instance, you may also print `4 3 2 1`.
{
"problem": {
"name": "Tree and LCS",
"description": {
"content": "We have a tree $T$ with vertices numbered $1$ to $N$. The $i$\\-th edge of $T$ connects vertex $u_i$ and vertex $v_i$. Let us use $T$ to define the **similarity** of a permutation $P = (P_1,P_2,\\ldots,",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc156_c"
},
"statements": [
{
"statement_type": "Markdown",
"content": "We have a tree $T$ with vertices numbered $1$ to $N$. The $i$\\-th edge of $T$ connects vertex $u_i$ and vertex $v_i$.\nLet us use $T$ to define the **similarity** of a permutation $P = (P_1,P_2,\\ldots,...",
"is_translate": false,
"language": "English"
}
]
}