結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2020-02-28 15:53:54 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 93 ms / 2,000 ms |
コード長 | 711 bytes |
コンパイル時間 | 389 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-10-13 16:26:14 |
合計ジャッジ時間 | 1,628 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # %% T = int(readline()) query = readlines() # %% def solve(q): w_min = 0 w_max = 0 g = 0 for a in q.rstrip().decode(): if a == 'W': w_min = 1 w_max += 1 elif a == 'G': if not w_max: return False w_min = 0 w_max -= 1 g += 1 else: if not g: return False g -= 1 return w_min == 0 and g == 0 # %% answers = ('possible' if solve(q) else 'impossible' for q in query) print('\n'.join(answers))