結果
問題 | No.154 市バス |
ユーザー | kichirb3 |
提出日時 | 2018-04-02 08:18:42 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 970 bytes |
コンパイル時間 | 99 ms |
コンパイル使用メモリ | 10,868 KB |
実行使用メモリ | 8,416 KB |
最終ジャッジ日時 | 2023-09-08 13:18:16 |
合計ジャッジ時間 | 1,441 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 83 ms
8,276 KB |
testcase_01 | AC | 84 ms
8,272 KB |
testcase_02 | AC | 83 ms
8,416 KB |
testcase_03 | AC | 66 ms
8,152 KB |
testcase_04 | AC | 77 ms
8,408 KB |
testcase_05 | AC | 16 ms
7,972 KB |
testcase_06 | AC | 16 ms
7,764 KB |
testcase_07 | AC | 115 ms
8,296 KB |
testcase_08 | AC | 16 ms
7,772 KB |
ソースコード
# -*- coding: utf-8 -*- """ No.154 市バス https://yukicoder.me/problems/no/154 """ import sys from sys import stdin input = stdin.readline def solve(S): G_stack = [] W_stack = [] need_G = False for s in S: if s == 'W': W_stack.append(1) need_G = True elif s == 'G': need_G = False if len(W_stack) == 0: return 'impossible' else: _ = W_stack.pop() G_stack.append(1) elif s == 'R': if len(G_stack) == 0: return 'impossible' else: _ = G_stack.pop() if len(G_stack) != 0: return 'impossible' if need_G is True: return 'impossible' return 'possible' def main(args): T = int(input()) for _ in range(T): S = input().strip() ans = solve(S) print(ans) if __name__ == '__main__': main(sys.argv[1:])