結果

問題 No.154 市バス
ユーザー MisterMister
提出日時 2020-04-22 11:18:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 71,996 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 10:31:02
合計ジャッジ時間 1,093 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

void solve() {
    std::string s;
    std::cin >> s;

    int wcnt = 0, gcnt = 0, rcnt = 0;
    for (char c : s) {
        if (c == 'W') {
            ++wcnt;
        } else if (c == 'G') {
            ++gcnt;
        } else if (c == 'R') {
            ++rcnt;
        }

        if (wcnt < gcnt || gcnt < rcnt) {
            std::cout << "impossible" << std::endl;
            return;
        }
    }

    std::cout << (gcnt == rcnt ? "possible" : "impossible")
              << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int q;
    std::cin >> q;
    while (q--) solve();

    return 0;
}
0