結果

問題 No.154 市バス
ユーザー JunOnumaJunOnuma
提出日時 2017-05-18 19:20:30
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 398 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-04-21 10:15:57
合計ジャッジ時間 1,635 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 10 ms
6,144 KB
testcase_06 AC 10 ms
6,272 KB
testcase_07 AC 160 ms
6,144 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(raw_input())
for _ in range(t):
    s = raw_input()
    ans = True
    cnt = 0
    for c in s:
        if c == 'G':
            cnt += 1
        elif c == 'R':
            cnt -= 1
            if cnt < 0:
                ans = False
                break
    if cnt != 0 or s[len(s)-2:] != 'GR':
        ans = False
    if ans:
        print 'possible'
    else:
        print 'impossible'
0