5 8 1 2 2 3 2 4 4 5
Yes
3 2 1 4 5
If $P=(3,2,1,4,5)$, then $f(P)$ is determined as follows:
* The simple path from vertex $1$ to vertex $1$ is $(1)$, and the length of the longest increasing subsequence of $(P_1)=(3)$ is $1$. Thus, $L_1 = 1$.
* The simple path from vertex $1$ to vertex $2$ is $(1,2)$, and the length of the longest increasing subsequence of $(P_1,P_2)=(3,2)$ is $1$. Thus, $L_2 = 1$.
* The simple path from vertex $1$ to vertex $3$ is $(1,2,3)$, and the length of the longest increasing subsequence of $(P_1,P_2,P_3)=(3,2,1)$ is $1$. Thus, $L_3 = 1$.
* The simple path from vertex $1$ to vertex $4$ is $(1,2,4)$, and the length of the longest increasing subsequence of $(P_1,P_2,P_4)=(3,2,4)$ is $2$. Thus, $L_4 = 2$.
* The simple path from vertex $1$ to vertex $5$ is $(1,2,4,5)$, and the length of the longest increasing subsequence of $(P_1,P_2,P_4,P_5)=(3,2,4,5)$ is $3$. Thus, $L_5 = 3$.
* From the above, $f(P)=1+1+1+2+3= 8$.
Hence, the permutation $P$ in the sample output satisfies the condition $f(P)=8$. Besides, $P=(3,2,4,5,1)$ also satisfies the condition, for example.7 21 2 1 7 2 5 1 3 7 2 6 3 4
No It can be proved that no permutation $P$ satisfies $f(P) = 21$.
8 20 3 1 3 8 7 1 7 5 3 2 6 5 4 7
Yes 2 1 3 5 6 8 4 7
{
"problem": {
"name": "LIS on Tree 2",
"description": {
"content": "There is a tree with $N$ vertices numbered $1$ to $N$. The $i$\\-th edge of the tree connects vertices $u_i$ and $v_i$ bidirectionally. For a permutation $P=(P_1,\\ldots,P_N)$ of $(1,\\ldots,N)$, we defi",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc175_d"
},
"statements": [
{
"statement_type": "Markdown",
"content": "There is a tree with $N$ vertices numbered $1$ to $N$. The $i$\\-th edge of the tree connects vertices $u_i$ and $v_i$ bidirectionally.\nFor a permutation $P=(P_1,\\ldots,P_N)$ of $(1,\\ldots,N)$, we defi...",
"is_translate": false,
"language": "English"
}
]
}