結果

問題 No.154 市バス
ユーザー rogi52rogi52
提出日時 2022-08-13 15:17:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 202,360 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 23:31:44
合計ジャッジ時間 2,778 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int T; cin >> T;
    rep(_,T) {
        string S; cin >> S;
        int W = 0, G = 0, R = 0;
        int N = S.size();
        int ans = 1;
        rep(i,N) {
            if(S[i] == 'W') W++;
            if(S[i] == 'G') {
                G++, W--;
                if(W < 0){ ans = 0; break; }
            }
            if(S[i] == 'R') {
                R++, G--;
                if(G < 0){ ans = 0; break; }
            }
        }

        if(G > 0) ans = 0;
        cout << string(ans ? "" : "im") + "possible" << endl;
    }
}
0