結果

問題 No.154 市バス
ユーザー Miutsuru kariyaMiutsuru kariya
提出日時 2016-06-30 10:04:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 64,736 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:49:21
合計ジャッジ時間 1,796 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

int main()
{
    int T;
    std::cin >> T;
    for (int i = 0; i < T; ++i) {
        std::string S;
        std::cin >> S;
        int W = 0;
        int G = 0;
        int R = 0;
        bool ng = false;
        bool l = false;
        for (auto c : S) {
            if (c == 'W') {
                ++W;
                l = true;
            } else if (c == 'G') {
                ++G;
                l = false;
                ng = G > W;
            } else {
                ++R;
                ng = R > G;
            }
            if (ng) {
                break;
            }
        }
        ng = ng || G != R || l;
        std::cout << (ng ? "im" : "") << "possible\n";
    }
}
0