結果
| 問題 |
No.2254 Reverse Only
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:03:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,415 bytes |
| コンパイル時間 | 326 ms |
| コンパイル使用メモリ | 82,508 KB |
| 実行使用メモリ | 159,796 KB |
| 最終ジャッジ日時 | 2025-04-15 23:05:22 |
| 合計ジャッジ時間 | 8,782 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 41 WA * 6 |
ソースコード
from collections import defaultdict
def main():
import sys
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
if k == 1:
if sorted(A) == sorted(B):
print("Yes")
else:
print("No")
return
if k > N:
if A == B:
print("Yes")
else:
print("No")
return
if sorted(A) != sorted(B):
print("No")
return
if k % 2 == 0:
print("Yes")
return
else:
# Check parity for each element's positions
parities_a = defaultdict(list)
parities_b = defaultdict(list)
for idx in range(N):
x = A[idx]
parities_a[x].append( (idx + 1) % 2 ) # 1-based parity
for idx in range(N):
x = B[idx]
parities_b[x].append( (idx + 1) % 2 )
# Check all elements have the same parity counts
for x in parities_a:
list_a = sorted(parities_a[x])
list_b = sorted(parities_b.get(x, []))
if list_a != list_b:
print("No")
return
print("Yes")
return
if __name__ == "__main__":
main()
lam6er