結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2015-04-09 18:18:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,107 bytes |
コンパイル時間 | 1,150 ms |
コンパイル使用メモリ | 160,692 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 07:20:33 |
合計ジャッジ時間 | 1,782 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 6 WA * 2 |
ソースコード
#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; bool ng = false; for (int i = 0; i < n; i++) { switch (s[i]) { case 'W': w++; break; case 'G': w--; if (w < 0) { ng = true; } g++; break; case 'R': g--; if (g < 0) { ng = true; } break; } if (ng) break; } if (g > 0) ng = true; if (ng) cout << "impossible" << endl; else cout << "possible" << endl; } return 0; }