結果

問題 No.154 市バス
ユーザー sei0osei0o
提出日時 2017-10-18 20:07:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,091 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 91,000 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-03 12:29:27
合計ジャッジ時間 1,608 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 23 ms
4,376 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 == 0 || r == 0) && w > 0) || (g != r || w % g > 0 || w % r > 0)) {
            possible = false;
        }

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

    return 0;
}
0