結果

問題 No.154 市バス
ユーザー mkawa2mkawa2
提出日時 2019-12-24 18:41:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 988 bytes
コンパイル時間 792 ms
コンパイル使用メモリ 11,972 KB
実行使用メモリ 10,248 KB
最終ジャッジ日時 2023-10-22 06:53:08
合計ジャッジ時間 2,534 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def ok(s):
    cw = cg = cr = 0
    if s[0]!="W" or s[-1]!="R":return False
    for c in s[::-1]:
        if c=="R":
            cr+=1
        if c=="G":
            cg+=1
            if cg>cr:return False
        if c=="W":
            cw+=1
            if cg==0:return False
    if cr!=cg:return False
    if cw<cg:return False
    return True

def main():
    t=II()
    for _ in range(t):
        s=input()
        if ok(s):print("possible")
        else:print("impossible")

main()
0