結果

問題 No.154 市バス
ユーザー Miutsuru kariya
提出日時 2016-06-30 10:04:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 65,148 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 08:36:59
合計ジャッジ時間 1,212 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

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