結果
| 問題 |
No.3086 Re One Two
|
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2025-04-04 22:03:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 897 bytes |
| コンパイル時間 | 335 ms |
| コンパイル使用メモリ | 82,076 KB |
| 実行使用メモリ | 131,684 KB |
| 最終ジャッジ日時 | 2025-04-04 22:03:42 |
| 合計ジャッジ時間 | 10,660 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 25 |
ソースコード
from collections import defaultdict
N = int(input())
moji = []
for _ in range(N):
a,b = list(map(int,input().split()))
moji.append((a,b))
ans = []
stack = []
onetwo = []
must = defaultdict(list)
for i in range(N):
a,b = moji[i]
if(a == 1 and b == 0):
stack.append(i)
elif(a == 1 and b == 1):
stack.append(onetwo.pop())
stack.append(i)
elif(a == 0 and b == 2):
onetwo.append(i)
if(stack):
must[i] += stack.copy()
stack = []
elif(a == 0 and b == 1):
ans.append(i)
v = onetwo.pop()
ans.append(v)
while(must[v]):ans.append(must[v].pop())
elif(a == 0 and b == 0):
ans.append(i)
while(stack):
v = stack.pop()
ans.append(v)
for i in must[v]:
ans.append(i)
else:
1/0
for i in ans:
print(i+1)
回転