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