結果

問題 No.154 市バス
ユーザー kagasan
提出日時 2019-08-22 22:12:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 773 bytes
コンパイル時間 1,512 ms
コンパイル使用メモリ 168,180 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-13 04:27:15
合計ジャッジ時間 2,321 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    ll T;
    cin >> T;
    for(ll t = 0; t < T; t++){
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        ll flg = 1;
        ll r = 0, g = 0, w = 0;
        for(ll i = 0; i < s.size(); i++){
            if(s[i] == 'R')r++;
            if(s[i] == 'G'){
                if(r == 0)flg = 0;
                else{
                    r--;
                    g++;
                }
            }
            if(s[i] == 'W'){
                if(g == 0)flg = 0;
                w++;
            }
        }
        if(r > 0)flg = 0;
        if(g > w)flg = 0;
        if(flg)cout << "possible" << endl;
        else cout << "impossible" << endl;
    }

    return 0;
}
0