結果
問題 | No.1328 alligachi-problem |
ユーザー | chineristAC |
提出日時 | 2020-12-25 00:37:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 688 ms / 2,000 ms |
コード長 | 1,069 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 110,336 KB |
最終ジャッジ日時 | 2024-09-21 17:15:12 |
合計ジャッジ時間 | 16,807 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
import sys input = sys.stdin.readline N = int(input()) dic = {"RR":[],"RB":[],"BR":[],"BB":[]} for _ in range(N): c,x,y = input().split() y = int(y) dic[c+x].append((y,_+1)) for color in dic: dic[color].sort(reverse=True) ans = [] R,B = 0,0 while len(ans)<N: if dic["BR"] and dic["BR"][-1][0]==R: if dic["RB"] and dic["RB"][-1][0]==B: exit(print("No")) elif dic["BB"] and dic["BB"][-1][0]==B: ans.append(dic["BB"].pop()[1]) B += 1 else: ans.append(dic["BR"].pop()[1]) B += 1 elif dic["RB"] and dic["RB"][-1][0]==B: if dic["RR"] and dic["RR"][-1][0]==R: ans.append(dic["RR"].pop()[1]) R += 1 else: ans.append(dic["RB"].pop()[1]) R += 1 elif dic["RR"] and dic["RR"][-1][0]==R: ans.append(dic["RR"].pop()[1]) R += 1 elif dic["BB"] and dic["BB"][-1][0]==B: ans.append(dic["BB"].pop()[1]) B += 1 else: exit(print("No")) print("Yes") print(*ans)