結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2018-10-13 04:16:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,083 bytes |
コンパイル時間 | 1,221 ms |
コンパイル使用メモリ | 95,844 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 17:56:51 |
合計ジャッジ時間 | 1,430 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 7 WA * 1 |
ソースコード
#include <cstdio>#include <cstring>#include <string>#include <iostream>#include <cmath>#include <bitset>#include <vector>#include <map>#include <set>#include <queue>#include <deque>#include <algorithm>#include <unordered_map>#include <unordered_set>#include <random>using namespace std;typedef long long int ll;typedef pair<int, int> P;int main(){int t;cin>>t;for(int i=0; i<t; i++){string s;cin>>s;vector<int> g, r;for(int j=0; j<s.size(); j++){if(s[j]=='G') g.push_back(j);else if(s[j]=='R') r.push_back(j);}if(g.size()!=r.size()){cout<<"impossible"<<endl;continue;}reverse(g.begin(), g.end());reverse(r.begin(), r.end());bool nuee=0;while(!g.empty()){if(g.back()>r.back()){cout<<"impossible"<<endl; nuee=1;break;}g.pop_back();r.pop_back();}if(nuee) continue;for(int j=s.size()-1; j>=0; j--){if(s[j]=='R') continue;if(s[j]!='G'){cout<<"impossible"<<endl; nuee=1;break;}break;}if(nuee) continue;cout<<"possible"<<endl;}return 0;}