結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2016-10-05 10:19:41 |
言語 | Python2 (2.7.18) |
結果 |
TLE
|
実行時間 | - |
コード長 | 860 bytes |
コンパイル時間 | 70 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 16,768 KB |
最終ジャッジ日時 | 2024-10-13 08:44:17 |
合計ジャッジ時間 | 6,498 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | TLE * 1 -- * 7 |
ソースコード
def solve(s):numG, numR = s.count('G'), s.count('R')if numG != numR or numG == 0:return Falsestacks = []for light in s:if light == 'R':stacks.append(1)elif light == 'G':for i in xrange(len(stacks)):if stacks[i] == 1:stacks[i] += 1breakelse:return Falseelse:if len(stacks) == 0 or max(stacks) == 1:return Falsefor i in xrange(len(stacks)):if stacks[i] == 2:stacks[i] += 1if len(stacks) == numG and min(stacks) == 3:return Truebreakreturn Truefor t in xrange(input()):print 'possible' if solve(raw_input()[::-1]) else 'impossible'