No.2254 Reverse Only
Problem Statement
You are given integer sequences $A=(A_1,A_2,\dots ,A_N),B=(B_1,B_2,\dots ,B_N)$ of length $N$ and a positive integer $k$.
Determine whether it is possible to make $A$ equal to $B$ by performing the following operation $0$ or more times.
Constraints
Input
$N$ $k$ $A_1$ $A_2$ $\dots A_N$ $B_1$ $B_2$ $\dots B_N$
Output
Print Yes if it is possible to make $A$ equal to $B$ by performing the operation $0$ or more times, and No otherwise.
Sample
Sample 1
Input
4 3 3 4 1 2 1 2 3 4
Output
Yes
They can be made equal with $2$ operations.
For the $1$st operation, let $l=1,r=3$. For the $2$nd operation, let $l=2,r=4$. The sequence $A$ changes as follows.
3 4 1 2 $\rightarrow$ 1 4 3 2 $\rightarrow$ 1 2 3 4
Since $A$ can be made equal to $B$, print Yes.
Sample 2
Input
5 6 1 2 3 4 5 1 2 3 4 5
Output
Yes
No operation can be performed, but they are equal from the beginning.
Sample 3
Input
3 1 3 1 4 1 5 9
Output
No
They cannot be made equal.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
noya2
Nachia