結果

問題 No.154 市バス
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-01-19 12:48:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 873 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 105,344 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-09-03 22:23:29
合計ジャッジ時間 5,121 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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