結果

問題 No.154 市バス
ユーザー eithiaeithia
提出日時 2015-02-18 03:41:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 739 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 159,244 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 08:01:21
合計ジャッジ時間 2,307 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

bool solve()
{
    string s;
    cin >> s;
    int w = 0, g = 0;
    for (char c : s) {
        if (c == 'W') {
            w = 1;
        } else if (c == 'G') {
            w = 0, ++g;
        } else if (c == 'R') {
            --g;
        }
        if (g < 0) return false;
    }
    return w == 0 and g == 0;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int t;
    for (cin >> t; t--; ) {
        cout << (solve() ? "possible" : "impossible") << endl;
    }
}
0