結果

問題 No.154 市バス
ユーザー kroton
提出日時 2016-06-19 22:54:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 1,180 ms
コンパイル使用メモリ 161,456 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 08:32:13
合計ジャッジ時間 1,870 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 2 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

bool check(string S){
    int w = 0, ws = 0, g = 0;
    for(char c : S){
        if(c == 'W') ++w;
        if(c == 'G'){
		if ((ws += w - 1) < 0) return false;
		++g;
        }
        if(c == 'R' && --g < 0) return false;
    }
    return (w == 0 && g == 0);
}

int main(){
    int T;
    cin >> T;

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

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

    return 0;
}
0