結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2017-02-05 21:55:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 883 bytes |
コンパイル時間 | 449 ms |
コンパイル使用メモリ | 59,812 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 08:57:37 |
合計ジャッジ時間 | 1,125 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 6 WA * 2 |
ソースコード
#include <cstdio> #include <iostream> #include <cmath> #include <string> #define rep(n) for(int i = 0; i < n; ++i) using namespace std; int main(void) { int t; cin >> t; rep(t) { int c = 0, log = 0, count = 0; bool flag = true; string str; cin >> str; if (str[str.size() - 1] == 'W') { cout << "impossible" << endl; break; } if(str.size()) rep(str.size()) { if (str[i] == 'G') { ++c, ++count; if (!log && i != str.size() - 1) { if (str[i + 1] == 'W') { log = 1; } else { log = 2; } } } else if (str[i] == 'R') { --c; } if (c < 0) { flag = false; break; } } if (count == 1 && log == 1) { flag = false; } if (flag) { if (c == 0) { cout << "possible" << endl; } else { cout << "impossible" << endl; } } else { cout << "impossible" << endl; } } }