結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2016-06-19 23:45:44 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 928 bytes |
コンパイル時間 | 466 ms |
コンパイル使用メモリ | 55,516 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 08:33:27 |
合計ジャッジ時間 | 1,101 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 7 WA * 1 |
ソースコード
#include <iostream> #include <string> using namespace std; string s; bool replace_before(char c, char c2, int n) { for(int i = n - 1; i >= 0; i--) { if (s[i] == c) { s[i] = '#'; return true; } } return false; } int main() { int T; cin >> T; for(int t = 0; t < T; t++) { cin >> s; int w = 0, g = 0, r = 0; bool ok = true; bool extra_w = false; for (int i = 0; i < s.length(); i++) { if (s[i] == 'W') { w++; extra_w = true; } if (s[i] == 'G') { g++; extra_w = false; if (--w < 0) { ok = false; break; } } if (s[i] == 'R') { r++; if (--g < 0) { ok = false; break; } } } if (ok && !extra_w) cout << "possible" << endl; else cout << "impossible" << endl; } }