結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2015-02-17 23:29:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 1,038 bytes |
コンパイル時間 | 580 ms |
コンパイル使用メモリ | 68,388 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 06:19:24 |
合計ジャッジ時間 | 1,239 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
//#define NDEBUG#include <iostream>#include <cstring>#include <algorithm>#include <vector>#include <map>#include <queue>#include <set>#include <tuple>#include <cassert>#include <numeric>using namespace std;typedef long long ll;bool solve() {string s;cin >> s;int n = s.size();reverse(s.begin(), s.end());int d[3] = {};bool f = false;for (int i = 0; i < n; i++) {if (s[i] == 'R') {d[0]++;} else if (s[i] == 'G') {if (!d[0]) return false;d[0]--;d[1]++;} else {if (!f && !d[1]) return false;f = true;if (d[1]) {d[1]--;}d[2]++;}}if (d[0] || d[1]) return false;return true;}int main() {int t = 0;cin >> t;for (int i = 0; i < t; i++) {if (solve()) {cout << "possible" << endl;} else {cout << "impossible" << endl;}}return 0;}