結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2015-10-14 16:59:55 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 265 ms / 2,000 ms |
コード長 | 717 bytes |
コンパイル時間 | 47 ms |
コンパイル使用メモリ | 6,784 KB |
実行使用メモリ | 6,400 KB |
最終ジャッジ日時 | 2024-10-13 07:42:55 |
合計ジャッジ時間 | 2,420 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#!/usr/bin/python # -*- coding: utf-8 -*- # roiti46 さんのをカンニング T = input() for t in range(T): inp = raw_input() w = last = 0 needG = False # last: 要終電本数 # needG: 要緑 t/f for s in inp: #緑より多く赤 or 白より多く緑 はだめ if s == 'G': last += 1 w -= 1 needG = False elif s == 'R': last -= 1 else: #s == 'W' w += 1 needG = True if last < 0 or w < 0: print 'impossible' break else: if last == 0 and needG == False: print 'possible' else: print 'impossible'