結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2021-03-14 14:16:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 876 bytes |
コンパイル時間 | 2,670 ms |
コンパイル使用メモリ | 192,372 KB |
最終ジャッジ日時 | 2025-01-19 16:37:16 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 3 WA * 5 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long;int main(){int t;string s;cin >> t;while(t--){cin >> s;bool ok = true;int g = 0,r = 0;if(s[s.size()-1] != 'R'){cout << "impossible" << endl;}else{for(int i=s.size()-1;i >= 0;i--){if(s[i] == 'W'){if(g > 0 && r > 0){g--;r--;}else if(r > 0 && g == 0){ok = false;r--;}}else if(s[i] == 'G'){if(r > 0) g++;else ok = false;}else if(s[i] == 'R'){r++;}}cout << (ok ? "possible" : "impossible") << endl;}}return 0;}