結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-04-02 08:18:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 130 ms / 2,000 ms |
| コード長 | 970 bytes |
| コンパイル時間 | 156 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-06-26 06:31:10 |
| 合計ジャッジ時間 | 1,547 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
# -*- 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:])
kichirb3