結果

問題 No.154 市バス
ユーザー sei0osei0o
提出日時 2017-10-18 20:04:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,030 bytes
コンパイル時間 830 ms
コンパイル使用メモリ 92,024 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 10:23:55
合計ジャッジ時間 1,671 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
    int T;
    cin >> T;
    for (int i = 0; i < T; i++) {
        string S;
        cin >> S;

        int w = 0, g = 0, r = 0;
        bool possible = true;
        for (int k = 0; k < S.length(); k++) {
            switch (S[k]) {
                case 'W':
                    w++;
                    break;
                case 'G':
                    g++;
                    if (w < g) possible = false;
                    break;
                case 'R':
                    r++;
                    if (w < r || g < r) possible = false;
                    break;
            }
            if (!possible) break;
        }
        if (g != r) {
            possible = false;
        }

        cout << (possible ? "possible" : "impossible") << endl;
    }

    return 0;
}
0