結果

問題 No.154 市バス
ユーザー 👑 CleyLCleyL
提出日時 2020-02-05 19:51:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 712 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 67,380 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 21:43:41
合計ジャッジ時間 1,533 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        string s;cin>>s;
        reverse(s.begin(),s.end());
        int nw = 0;
        bool ok = false;
        bool ans = true;
        for(int i = 0; s.size() > i; i++){
            if(s[i] == 'R')nw++;
            else if(s[i] == 'G'){
                nw--;
                ok = true;
                if(nw < 0){
                    ans = false;
                    break;
                }
            }else{
                if(!ok){
                    ans = false;
                    break;
                }
            }
        }
        cout << (ans?"possible":"impossible") << endl;
    }
}
0