結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2019-03-07 10:43:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,100 bytes |
コンパイル時間 | 493 ms |
コンパイル使用メモリ | 63,008 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 14:47:12 |
合計ジャッジ時間 | 1,270 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 WA * 2 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> bool solve(const std::string& s) { int cntR{}, cntG{}, cntW{}; for (const auto c : s) { if (c == 'R') { cntR++; } if (c == 'G') { if (cntR >= 1) { cntG++; cntR--; } else { return false; } } if (c == 'W') { if (cntG >= 1) { cntW++; cntG--; } else if (cntW >=1) { cntW++; } else { return false; } } if (cntR == 0 && cntG == 0) { return true; } } return false; } int main(int argc, char const* argv[]) { int T; std::cin >> T; std::vector<std::string> s(T); for (int i = 0; i < T; i++) { std::cin >> s[i]; std::reverse(s[i].begin(), s[i].end()); } for (int i = 0; i < T; i++) { std::cout << (solve(s[i]) ? "possible" : "impossible") << std::endl; } return 0; }