結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2019-04-21 19:55:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 737 bytes |
コンパイル時間 | 1,567 ms |
コンパイル使用メモリ | 167,752 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 06:30:17 |
合計ジャッジ時間 | 2,491 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false), cin.tie(nullptr);int T; cin >> T;while(T--){string S; cin >> S;int cr = 0, cg = 0, cw = 0;bool ok = true;reverse(S.begin(), S.end());for(auto c : S){if(c=='R') cr++;else if(c=='G'){if(cr==0) ok = false;else cr--, cg++;}else{if(cg==0 and cw == 0) ok = false;else if(cg) cg--, cw++;}}if(cr or cg) ok = false;if(ok) cout << "possible" << endl;else cout << "impossible" << endl;}return 0;}