結果

問題 No.154 市バス
ユーザー buey_tbuey_t
提出日時 2023-03-29 10:41:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,784 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 11,248 KB
最終ジャッジ日時 2023-10-21 03:18:33
合計ジャッジ時間 1,866 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
11,232 KB
testcase_01 AC 136 ms
11,232 KB
testcase_02 AC 134 ms
11,232 KB
testcase_03 AC 106 ms
11,232 KB
testcase_04 AC 126 ms
11,232 KB
testcase_05 WA -
testcase_06 AC 34 ms
11,184 KB
testcase_07 AC 124 ms
11,232 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    '''
    何をチェックすべきか
    まず、赤と緑の数が一致してるか
    緑赤の順番できているか
    
    
    '''
    
    for _ in range(int(input())):
        S = list(input())
        N = len(S)
        r = 0
        g = 0
        w = 0
        for i in range(N):
            if S[i] == 'G':
                g += 1
                if g > w:
                    break
            elif S[i] == 'R':
                r += 1
                if r > g:
                    break
            else:
                w += 1
        else:
            if r != g:
                print('impossible')
            elif S[-1] == 'W':
                print('impossible')
            else:
                print('possible')
            continue
        print('impossible')
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0