結果
| 問題 |
No.2254 Reverse Only
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 15:59:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 950 bytes |
| コンパイル時間 | 493 ms |
| コンパイル使用メモリ | 81,472 KB |
| 実行使用メモリ | 147,144 KB |
| 最終ジャッジ日時 | 2025-04-16 16:02:28 |
| 合計ジャッジ時間 | 7,627 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / 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()
lam6er