結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
11,288 KB
testcase_01 AC 118 ms
11,288 KB
testcase_02 AC 112 ms
11,288 KB
testcase_03 AC 93 ms
11,288 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 112 ms
11,288 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
        for i in range(N):
            if S[i] == 'G':
                g += 1
            elif S[i] == 'R':
                r += 1
                if r > g:
                    print('impossible')
                    break
        else:
            if r != g:
                print('impossible')
            else:
                print('possible')
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0