結果

問題 No.154 市バス
ユーザー MisterMister
提出日時 2020-04-22 11:17:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 602 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 70,368 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 10:29:47
合計ジャッジ時間 1,365 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

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

    int cnt = 0;
    for (char c : s) {
        if (c == 'G') {
            ++cnt;
        } else if (c == 'R') {
            --cnt;
            if (cnt < 0) {
                std::cout << "impossible" << std::endl;
                return;
            }
        }
    }

    std::cout << (cnt == 0 ? "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