結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2015-04-09 18:30:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,301 bytes |
コンパイル時間 | 1,248 ms |
コンパイル使用メモリ | 158,556 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 07:20:46 |
合計ジャッジ時間 | 1,835 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 7 WA * 1 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); int T; cin >> T; while (T--) { string s; cin >> s; int n = s.size(); int g = 0, w = 0, r = 0; int cnt = 0; bool ng = false; bool after = false; for (int i = 0; i < n; i++) { switch (s[i]) { case 'W': w++; after = true; break; case 'G': g++; if (w < g) { ng = true; } break; case 'R': r++; if (g < r) { ng = true; } else if (r == g) { after = false; } cnt++; break; } if (ng) break; } if (g != r || cnt == 0 || after) ng = true; if (ng) cout << "impossible" << endl; else cout << "possible" << endl; } return 0; }