結果

問題 No.154 市バス
ユーザー buey_tbuey_t
提出日時 2023-03-29 10:34:32
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,556 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 81,524 KB
実行使用メモリ 88,352 KB
最終ジャッジ日時 2023-10-21 03:14:05
合計ジャッジ時間 2,565 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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
        for i in range(S):
            if S[i] == 'G':
                g += 1
            elif S[i] == 'R':
                r += 1
                if r > g:
                    print('impossible')
                    exit()
    if r != g:
        print('impossible')
    else:
        print('possible')
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0