結果
| 問題 |
No.1051 PQ Permutation
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2020-05-08 23:11:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,237 bytes |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 270,952 KB |
| 最終ジャッジ日時 | 2024-07-05 19:59:19 |
| 合計ジャッジ時間 | 4,855 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 6 TLE * 1 -- * 33 |
ソースコード
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)
if flag1 and flag2:
print(*B)
else:
print(-1)
brthyyjp