問題一覧 > 通常問題

No.2254 Reverse Only

レベル : / AI推定難易度 : 1900 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 48
作問者 : noya2 / テスター : shobonvip 👑 Nachia
お気に入りにしたユーザー ProblemId : 9150 / 自分の提出
問題文最終更新日: 2023-03-24 19:06:32
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 382 (順位表) の他の問題:

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.

  • Choose integers $l,r$ satisfying $1\le l\le r\le N, r - l + 1 \ge k$.
  • Reverse the $l$-th through $r$-th terms of $A$. That is, simultaneously replace $A_l,A_{l+1},\dots ,A_{r-1},A_r$ with $A_r,A_{r-1},\dots ,A_{l+1},A_l$.
  • Constraints

  • All input values are integers.
  • $1\le N\le 2\times 10^5$
  • $1\le k\le 2\times 10^5$
  • $1\le A_i,B_i\le 2\times 10^5\ (1\le i\le N)$
  • 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もしくは右上の雲マークをクリックしてアカウントを作成してください。