結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2019-08-22 22:16:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 1,561 ms |
コンパイル使用メモリ | 168,544 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 04:35:53 |
合計ジャッジ時間 | 2,333 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; int main(){ ll T; cin >> T; for(ll t = 0; t < T; t++){ string s; cin >> s; reverse(s.begin(), s.end()); ll flg = 1; ll r = 0, g = 0, w = 0, gg = 0; for(ll i = 0; i < s.size(); i++){ if(s[i] == 'R')r++; if(s[i] == 'G'){ if(r == 0)flg = 0; else{ r--; g++; gg = 1; } } if(s[i] == 'W'){ if(gg == 0)flg = 0; if(g)g--; } } if(r > 0)flg = 0; if(g > 0)flg = 0; if(flg)cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }