結果

問題 No.154 市バス
ユーザー CleyLCleyL
提出日時 2020-02-05 20:25:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 67,588 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 05:30:50
合計ジャッジ時間 1,721 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
4,348 KB
testcase_01 AC 29 ms
4,348 KB
testcase_02 AC 29 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 25 ms
4,348 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

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&&ok?"possible":"impossible") << endl;
    }
}
0