結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2015-02-20 22:34:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,829 bytes |
コンパイル時間 | 1,290 ms |
コンパイル使用メモリ | 158,364 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 07:00:10 |
合計ジャッジ時間 | 1,935 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 1 |
ソースコード
#include<bits/stdc++.h>using namespace std;typedef long long int ll;typedef pair<int, int> pii;typedef vector<int> vi;typedef vector<pair<int, int> > vii;#define rrep(i, m, n) for(int (i)=(m); (i)<(n); (i)++)#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)#define rev(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)#define vrep(i, c) for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)#define ALL(v) (v).begin(), (v).end()#define mp make_pair#define pb push_backtemplate<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }const int INF = 1000000000;const ll MOD = 1000000007LL;const double EPS = 1E-12;int T;string s;int main(){cin >> T;while(T--){int G = 0;int R = 0;int GR = 0;int W = 0;bool ok = false;cin >> s;if(s.size() < 3){puts("impossible");continue;}rep(i, s.size()){if(s[i] == 'G'){if(W > 0){ok = false;W -= 1;}GR += 1;G += 1;}if(s[i] == 'R'){//if(W > 0) W -= 1;GR -= 1;R += 1;}if(s[i] == 'W') if(G > 0 && !ok){ok = true;// if(s[i-1] != 'G') continue;while(s[i+1] == 'W') i++;W += 1;}if(GR < 0) break;}if(G < 1 || R < 1 || G != R) GR = -1;if(W > 0) GR = -1;puts(GR ? "impossible" : "possible");// cerr << W << " " << G << " " << R << endl;}return 0;}