結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2021-03-14 13:15:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 763 bytes |
コンパイル時間 | 1,931 ms |
コンパイル使用メモリ | 192,240 KB |
最終ジャッジ日時 | 2025-01-19 16:24:00 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 5 WA * 3 |
ソースコード
#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 = false;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){ok = true;g--;r--;}}else if(s[i] == 'G'){if(r > 0) g++;}else if(s[i] == 'R'){r++;}}cout << (ok ? "possible" : "impossible") << endl;}}return 0;}