結果
| 問題 |
No.2740 Old Maid
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2024-04-20 10:28:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 468 bytes |
| コンパイル時間 | 369 ms |
| コンパイル使用メモリ | 82,560 KB |
| 実行使用メモリ | 143,936 KB |
| 最終ジャッジ日時 | 2024-10-12 06:00:38 |
| 合計ジャッジ時間 | 11,305 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 53 WA * 9 |
ソースコード
N = int(input())
P = list(map(int, input().split())) + ["$"]
nex = [-1] * (N + 1)
pre = [-1] * (N + 1)
for i in range(N):
nex[P[i]] = P[i + 1]
pre[P[i]] = P[i - 1]
ans = []
S = set()
for i in range(1, N):
if nex[i] == "$" or i in S:
continue
ans.append(i)
ans.append(nex[i])
S.add(i)
S.add(nex[i])
p = pre[i]
n = nex[nex[i]]
if p != "$":
nex[p] = n
if n != "$":
pre[n] = p
print(*ans)
rlangevin