結果

問題 No.154 市バス
ユーザー lowrlowr
提出日時 2018-11-02 13:13:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 4,930 ms
コンパイル使用メモリ 169,756 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-12 21:15:33
合計ジャッジ時間 3,176 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

int main() {
    int t;
    std::cin >> t;
    while (t--) {
        std::string s;
        std::cin >> s;
        bool flg = true;
        int a = 0, w = 0;
        std::deque<int> q;
        for (auto c : s) {
            switch (c) {
                case 'W':
                w++;
                break;
                case 'G':
                q.push_back(1);
                a = std::max(a, (int)q.size());
                break;
                case 'R':
                if (q.size() == 0) {
                    goto g;
                } else {
                    q.pop_back();
                }
            }
        }
        std::cout << (q.size() == 0 && w >= a ? "possible" : "impossible") << std::endl;
        continue;
g:
        std::cout << "impossible" << std::endl;
    }
    return 0;
}
0