結果

問題 No.154 市バス
ユーザー yosupotyosupot
提出日時 2015-02-17 23:27:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 953 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 68,520 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 07:33:22
合計ジャッジ時間 1,202 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
5,248 KB
testcase_01 AC 24 ms
5,376 KB
testcase_02 AC 24 ms
5,376 KB
testcase_03 AC 24 ms
5,376 KB
testcase_04 AC 25 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 21 ms
5,376 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//#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] = {};
    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 (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;
}
0