結果

問題 No.2254 Reverse Only
ユーザー gew1fw
提出日時 2025-06-12 19:47:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,528 KB
実行使用メモリ 159,000 KB
最終ジャッジ日時 2025-06-12 19:47:46
合計ジャッジ時間 8,372 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    k = int(input[idx])
    idx += 1
    A = list(map(int, input[idx:idx+N]))
    idx += N
    B = list(map(int, input[idx:idx+N]))
    
    if A == B:
        print("Yes")
        return
    
    if k == 1:
        print("No")
        return
    
    if k > N:
        print("No")
        return
    
    if k == N:
        reversed_A = A[::-1]
        if B == reversed_A:
            print("Yes")
        else:
            print("No")
        return
    
    # Check if elements are the same
    if Counter(A) == Counter(B):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()
0