結果
問題 | No.154 市バス |
ユーザー | yaoshimax |
提出日時 | 2015-02-19 02:44:08 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 404 ms / 2,000 ms |
コード長 | 565 bytes |
コンパイル時間 | 720 ms |
コンパイル使用メモリ | 6,576 KB |
実行使用メモリ | 6,008 KB |
最終ジャッジ日時 | 2023-08-03 09:33:44 |
合計ジャッジ時間 | 3,569 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 404 ms
5,832 KB |
testcase_01 | AC | 400 ms
5,900 KB |
testcase_02 | AC | 399 ms
6,008 KB |
testcase_03 | AC | 320 ms
6,004 KB |
testcase_04 | AC | 399 ms
5,904 KB |
testcase_05 | AC | 11 ms
5,956 KB |
testcase_06 | AC | 11 ms
5,864 KB |
testcase_07 | AC | 300 ms
5,828 KB |
testcase_08 | AC | 11 ms
5,860 KB |
ソースコード
T=int(raw_input()) for i in range(T): S=raw_input() Rcnt=0 Gcnt=0 ok=True oneBus =False for s in S[::-1]: if s=='R': Rcnt+=1 if s=='G': if Rcnt <= 0: ok=False break Rcnt-=1 Gcnt+=1 if s=='W': if Gcnt <= 0 and oneBus==False: ok=False break Gcnt=max(0,Gcnt-1) oneBus = True if ok and Rcnt==0 and Gcnt==0: print 'possible' else: print 'impossible'