結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2016-06-19 23:27:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 856 bytes |
コンパイル時間 | 544 ms |
コンパイル使用メモリ | 55,636 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 08:32:55 |
合計ジャッジ時間 | 1,264 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 6 WA * 2 |
ソースコード
#include <iostream> #include <string> using namespace std; string s; bool delete_before(char c, 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; if (s[s.length() - 1] != 'R') { cout << "impossible" << endl; continue; } bool ok = true; for (int i = 0; i < s.length(); i++) { if (s[i] == 'G') { if (!delete_before('W', i)) { ok = false; break; } } if (s[i] == 'R') { if (!delete_before('G', i)) { ok = false; break; } } } if (ok) cout << "possible" << endl; else cout << "impossible" << endl; } }