結果
| 問題 |
No.1888 Odd Insertion
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:30:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,592 bytes |
| コンパイル時間 | 590 ms |
| コンパイル使用メモリ | 82,324 KB |
| 実行使用メモリ | 126,220 KB |
| 最終ジャッジ日時 | 2025-06-12 16:30:14 |
| 合計ジャッジ時間 | 13,898 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 WA * 10 TLE * 1 -- * 12 |
ソースコード
import bisect
def main():
import sys
input = sys.stdin.read
data = input().split()
N = int(data[0])
P = list(map(int, data[1:N+1]))
A = P.copy()
current_S = []
operations = []
for i in range(N, 0, -1):
found = False
max_y = min(i, len(A))
# First, check for odd y in descending order
for y in range(max_y, 0, -1):
if y % 2 == 1:
if y-1 >= len(A):
continue
x = A[y-1]
idx = bisect.bisect_left(current_S, x)
if idx == 0 or (idx == 1 and len(current_S) >= 1):
A.pop(y-1)
bisect.insort(current_S, x)
operations.append((x, y))
found = True
break
if not found:
# Check all y in descending order
for y in range(max_y, 0, -1):
if y-1 >= len(A):
continue
x = A[y-1]
idx = bisect.bisect_left(current_S, x)
if idx == 0 or (idx == 1 and len(current_S) >= 1):
A.pop(y-1)
bisect.insort(current_S, x)
operations.append((x, y))
found = True
break
if not found:
print("No")
return
# Reverse the operations to get the correct order
operations = operations[::-1]
print("Yes")
for x, y in operations:
print(x, y)
if __name__ == "__main__":
main()
gew1fw