結果
問題 |
No.2254 Reverse Only
|
ユーザー |
![]() |
提出日時 | 2025-04-15 23:11:35 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 950 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 81,664 KB |
実行使用メモリ | 147,100 KB |
最終ジャッジ日時 | 2025-04-15 23:13:52 |
合計ジャッジ時間 | 8,182 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 42 WA * 5 |
ソースコード
import sys from collections import defaultdict def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 k = int(input[ptr]) ptr += 1 A = list(map(int, input[ptr:ptr+N])) ptr += N B = list(map(int, input[ptr:ptr+N])) ptr += N # Check if A and B are permutations count = defaultdict(int) for x in A: count[x] += 1 for x in B: count[x] -= 1 if count[x] < 0: print("No") return if k == 1: print("Yes") return if k > N: if A == B or A[::-1] == B: print("Yes") else: print("No") return if k % 2 == 0: print("Yes") else: if N >= k + 1: print("Yes") else: if A == B or A[::-1] == B: print("Yes") else: print("No") if __name__ == "__main__": main()