結果
問題 | No.154 市バス |
ユーザー | ktshun |
提出日時 | 2015-06-09 13:00:32 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 250 ms / 2,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 6,684 KB |
実行使用メモリ | 6,136 KB |
最終ジャッジ日時 | 2023-08-03 10:05:09 |
合計ジャッジ時間 | 2,695 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 250 ms
5,972 KB |
testcase_01 | AC | 247 ms
5,976 KB |
testcase_02 | AC | 248 ms
5,984 KB |
testcase_03 | AC | 182 ms
6,100 KB |
testcase_04 | AC | 233 ms
6,100 KB |
testcase_05 | AC | 12 ms
5,972 KB |
testcase_06 | AC | 12 ms
6,040 KB |
testcase_07 | AC | 250 ms
5,992 KB |
testcase_08 | AC | 11 ms
6,136 KB |
ソースコード
# -*- coding:utf-8 -*- def solve(): s = raw_input() s = list(s) g = s.count("G") r = s.count("R") if g != r: print "impossible" return i = 1 gg = s[::-1].index("G") ww = s[::-1].index("W") if ww < gg: print "impossible" return while i <= g: gg = s[::-1].index("G") rr = s[::-1].index("R") if gg < rr: print "impossible" return s[len(s)-gg -1] = s[len(s) - rr -1] = "W" i += 1 print "possible" if __name__ == "__main__": n = input() for i in xrange(n): S = raw_input() need = False w = r = cnt = 0 for s in S: if s == "G": r += 1 w -= 1 need = False elif s == "R": r -= 1 else: w += 1 need = True if r < 0 or w < 0: print "impossible" break else: if r == 0 and not need: print "possible" else: print "impossible"