結果

問題 No.154 市バス
ユーザー rabimea
提出日時 2025-09-26 05:48:44
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 718 bytes
コンパイル時間 3,090 ms
コンパイル使用メモリ 277,756 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-26 05:48:49
合計ジャッジ時間 4,452 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>

using std::cin, std::cout, std::cerr;
using ll = long long;

bool Solve() {
    std::string s; cin >> s;
    std::ranges::reverse(s);
    int cnt = 0; bool white = 0;
    for(char c : s) {
        if(c == 'R') cnt ++;
        else if(c == 'G') {
            if(cnt == 0) return false;
            cnt --;
            white = 1;
        } else {
            if(!white) return false;
        }
    }
    return true;
}

int main() {
    std::ios::sync_with_stdio(false);
    int T; cin >> T;
    while(T --) {
        cout << (Solve() ? "possible" : "impossible") << '\n';
    }
}
0