結果

問題 No.154 市バス
ユーザー fmhrfmhr
提出日時 2015-02-18 03:24:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 409 ms / 2,000 ms
コード長 596 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 7,952 KB
最終ジャッジ日時 2023-08-03 09:19:36
合計ジャッジ時間 3,871 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 398 ms
7,864 KB
testcase_01 AC 395 ms
7,916 KB
testcase_02 AC 384 ms
7,864 KB
testcase_03 AC 387 ms
7,860 KB
testcase_04 AC 409 ms
7,780 KB
testcase_05 AC 16 ms
7,952 KB
testcase_06 AC 16 ms
7,864 KB
testcase_07 AC 402 ms
7,768 KB
testcase_08 AC 16 ms
7,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
ans = []
for i in range(t):
    s = list(input())
    f = 0
    flag = 1
    count_w = 0
    count_g = 0
    count_r = 0
    while s:
        wgr = s.pop(0)
        if wgr == 'W':
            count_w += 1
            flag = 1
        elif wgr == 'G':
            count_g += 1
            flag = 0
        elif wgr == 'R':
            count_r += 1
        if count_g < count_r or count_w < count_g:
            f = 1
    if f == 0 and flag == 0 and count_w >= count_g == count_r:
        ans.append('possible')
    else:
        ans.append('impossible')
for j in ans:
    print(j)
0