結果
| 問題 |
No.2254 Reverse Only
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 13:29:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 807 bytes |
| コンパイル時間 | 279 ms |
| コンパイル使用メモリ | 82,512 KB |
| 実行使用メモリ | 147,840 KB |
| 最終ジャッジ日時 | 2025-06-12 13:34:13 |
| 合計ジャッジ時間 | 8,864 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 42 WA * 5 |
ソースコード
from collections import defaultdict
def main():
import sys
input = sys.stdin.read().split()
idx = 0
N, k = int(input[idx]), int(input[idx+1])
idx +=2
A = list(map(int, input[idx:idx+N]))
idx +=N
B = list(map(int, input[idx:idx+N]))
# Check if A and B are permutations
count = defaultdict(int)
for a in A:
count[a] +=1
for b in B:
count[b] -=1
if count[b] <0:
print("No")
return
for v in count.values():
if v !=0:
print("No")
return
if k ==1 or k ==2:
print("Yes")
return
if N <k:
if A == B:
print("Yes")
else:
print("No")
else:
print("Yes")
if __name__ == "__main__":
main()
gew1fw