結果

問題 No.154 市バス
ユーザー nemutainemutai
提出日時 2023-03-29 09:59:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 1,576 ms
コンパイル使用メモリ 168,056 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 02:45:18
合計ジャッジ時間 2,271 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define all(v) v.begin(),v.end()
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;


int main(){
    ll T;
    cin>>T;
    while(T--){
        string S;
        cin>>S;
        ll N=S.size();
        bool a=true;
        bool b=false;
        for(int i=N-1;i>=0;i--){
            if(S[i]=='W')a=false;
            if(S[i]=='G'){
                if(!b)a=false;
                break;
            }
            if(S[i]=='R') b=true;
        }
        ll g=0;
        for(int i=0;i<N;i++){
            if(S[i]=='G')g++;
            if(S[i]=='R'){
                if(g<=0)a=false;
                g--;
            }
        }
        cout << (a?"possible":"impossible") << endl;
    }
}
    
0