結果

問題 No.1328 alligachi-problem
ユーザー chineristACchineristAC
提出日時 2020-12-25 00:37:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 657 ms / 2,000 ms
コード長 1,069 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 109,576 KB
最終ジャッジ日時 2023-10-21 16:00:41
合計ジャッジ時間 16,534 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,424 KB
testcase_01 AC 38 ms
53,424 KB
testcase_02 AC 38 ms
53,424 KB
testcase_03 AC 38 ms
53,424 KB
testcase_04 AC 68 ms
70,752 KB
testcase_05 AC 68 ms
72,792 KB
testcase_06 AC 48 ms
64,248 KB
testcase_07 AC 69 ms
72,808 KB
testcase_08 AC 41 ms
55,472 KB
testcase_09 AC 651 ms
104,776 KB
testcase_10 AC 534 ms
87,224 KB
testcase_11 AC 649 ms
106,096 KB
testcase_12 AC 648 ms
106,096 KB
testcase_13 AC 650 ms
105,564 KB
testcase_14 AC 655 ms
105,832 KB
testcase_15 AC 541 ms
87,340 KB
testcase_16 AC 651 ms
105,564 KB
testcase_17 AC 650 ms
105,568 KB
testcase_18 AC 647 ms
105,040 KB
testcase_19 AC 657 ms
105,304 KB
testcase_20 AC 654 ms
105,304 KB
testcase_21 AC 643 ms
105,568 KB
testcase_22 AC 654 ms
104,512 KB
testcase_23 AC 541 ms
87,228 KB
testcase_24 AC 627 ms
102,396 KB
testcase_25 AC 635 ms
102,416 KB
testcase_26 AC 441 ms
109,576 KB
testcase_27 AC 441 ms
109,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0