結果

問題 No.2254 Reverse Only
ユーザー lam6er
提出日時 2025-03-31 17:25:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 160,580 KB
最終ジャッジ日時 2025-03-31 17:26:51
合計ジャッジ時間 8,798 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 42 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

def main():
    import sys
    input = sys.stdin.read().split()
    ptr = 0
    N, k = int(input[ptr]), int(input[ptr+1])
    ptr += 2
    A = list(map(int, input[ptr:ptr+N]))
    ptr += N
    B = list(map(int, input[ptr:ptr+N]))
    ptr += N
    
    if A == B:
        print("Yes")
        return
    
    if Counter(A) != Counter(B):
        print("No")
        return
    
    if k == 1:
        print("Yes")
    elif k == 2:
        print("Yes")
    else:
        if N < k:
            print("No")
        else:
            if N > k:
                print("Yes")
            else:
                # N == k and k >=3
                if B == A[::-1]:
                    print("Yes")
                else:
                    print("No")
    
if __name__ == '__main__':
    main()
0