結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2023-08-29 09:46:39 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 579 ms / 2,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-12-30 23:08:47 |
合計ジャッジ時間 | 4,463 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
T = int(input())for i in range(T):s = input()L = len(s)wg = 0gr = 0f = Truefor i in range(L):if s[i] == 'W' :wg += 1elif s[i] == 'G':wg -= 1gr += 1elif s[i] == 'R':gr -= 1if not(0 <= gr and 0 <= wg):print('impossible')breakif s[L-i-1] == 'G':f = Falseif f and s[L-i-1] == 'W':print('impossible')breakelse:if gr == 0:print('possible')else:print('impossible')