結果
問題 |
No.1051 PQ Permutation
|
ユーザー |
![]() |
提出日時 | 2020-05-08 22:56:53 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,194 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 108,160 KB |
最終ジャッジ日時 | 2024-07-05 19:55:43 |
合計ジャッジ時間 | 10,032 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 32 |
ソースコード
n, p, q = map(int, input().split()) A = list(map(int, input().split())) C = list(range(1, n+1)) import heapq heapq.heapify(C) B = [0]*n flag1 = False flag2 = False for i in range(n): a = A[i] temp = [] while C: x = heapq.heappop(C) if not flag2: if x <= A[i]: temp.append(x) continue else: if x != q: B[i] = x break else: if flag1: B[i] = x break else: temp.append(x) continue else: if x != q: B[i] = x break else: if flag1: B[i] = x break else: temp.append(x) continue if B[i] == 0: #print(B) print(-1) exit() if B[i] == p: flag1 = True if not flag2: if B[i] > A[i]: flag2 = True while temp: y = temp.pop() heapq.heappush(C, y) print(*B)