結果

問題 No.154 市バス
ユーザー srjywrdnprkt
提出日時 2023-01-19 12:48:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 873 bytes
コンパイル時間 1,117 ms
コンパイル使用メモリ 104,560 KB
最終ジャッジ日時 2025-02-10 04:11:33
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 5 WA * 2 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;

int main(){

    int T, g;
    string S;
    cin >> T;

    while(T){
        cin >> S;
        g = 0;
        if (S.back() != 'R'){
            cout << "impossible" << endl;
            T--;
            continue;
        }

        for (int i=0; i<S.size(); i++){
            if (S[i] == 'G') g++;
            else if (S[i] == 'R'){
                if (g == 0){
                    T--;
                    cout << "impossible" << endl;
                    continue;
                }
                else g--;
            }
        }
        cout << (g == 0 ? "possible" : "impossible") << endl;
        T--;
    }

    return 0;
}
0