結果

問題 No.154 市バス
ユーザー mkawa2mkawa2
提出日時 2019-12-24 18:25:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,065 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 12,056 KB
実行使用メモリ 10,256 KB
最終ジャッジ日時 2023-10-22 06:28:26
合計ジャッジ時間 1,963 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 main():
    t=II()
    for _ in range(t):
        s=input()
        cw=cg=cr=0
        for c in s:
            if c=="W":
                cw+=1
            if c=="G":
                cg+=1
                if cg>cw:
                    print("impossible")
                    break
            if c=="R":
                cr+=1
                if cr>cg or cr>cw:
                    print("impossible")
                    break
        else:
            if cr==cg:
                print("possible")
            else:
                print("impossible")

main()
0