結果

問題 No.154 市バス
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-04-18 22:29:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,547 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 73,296 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 16:25:57
合計ジャッジ時間 1,898 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    int t;
    int w, g, r,f;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        string s;
        cin >> s;
        w = g = r = f = 0;
        bool miss = false;
        for (int j = 0; j < s.length(); j++)
        {
            switch (s[j]) {
                case 'W':
                    w++;
                    f = 1;
                    break;
                case 'G':
                    if (w <= g) {
                        miss = true;
                    }
                    else {
                        g++;
                        if (f = 1) f++;
                    }
                    break;
                case 'R':
                    if (g <= r) {
                        miss = true;
                    }
                    else {
                        r++;
                        if (f = 2) f++;
                    }
                    break;
            }
            if (miss) break;
        }
        if (miss || g != r || g == 0 || f != 3) cout << "impossible" << endl;
        else cout << "possible" << endl;
    }
    getchar(); getchar();
    return 0;
}
0