結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2016-07-22 19:41:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,460 bytes |
コンパイル時間 | 1,260 ms |
コンパイル使用メモリ | 159,664 KB |
実行使用メモリ | 6,816 KB |
最終ジャッジ日時 | 2024-10-13 08:41:16 |
合計ジャッジ時間 | 1,896 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 1 |
ソースコード
#include <bits/stdc++.h> #define REP(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) using namespace std; typedef int64_t ll; const int INF = 1e8; const double EPS = 1e-10; int main() { ios_base::sync_with_stdio(false); string s; int n; cin >> n; while(n--) { int r = 0, g = 0, w = 0; bool ok = true; cin >> s; for(int i = 0; i < s.size(); i++) { char c = s[i]; if(c == 'W') { w++; } if(c == 'G') { g++; if(g > w) { ok = false; } } if(c == 'R') { r++; if(r > g) { ok = false; } } } if(s.back() != 'R') ok = false; if(g > w) ok = false; if(r > g) ok = false; for(int i = 0; i < s.size(); i++) { char c = s[i]; if(c == 'W') { if(r == 0 or g == 0) { ok = false; } w--; } if(c == 'G') { if(r == 0) { ok = false; } g--; } if(c == 'R') { r--; } } if(ok) { cout << "possible" << endl; } else { cout << "impossible" << endl; } } }