結果

問題 No.154 市バス
ユーザー tatsukawa
提出日時 2016-07-22 19:27:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 955 bytes
コンパイル時間 1,243 ms
コンパイル使用メモリ 158,936 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 08:40:55
合計ジャッジ時間 1,757 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define REP(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

using namespace std;

typedef int64_t ll;

const int INF = 1e8;
const double EPS = 1e-10;

int main() {
    ios_base::sync_with_stdio(false);
    string s;
    int n;
    cin >> n;

    while(n--) {
        int r = 0, g = 0, w = 0;
        bool ok = true;
        cin >> s;

        for(int i = 0; i < s.size(); i++) {
            char c = s[i];
            if(c == 'W') {
                w++;
            }
            if(c == 'G') {
                g++;
                if(w < g) {
                    ok = false;
                }
            } 
            if(c == 'R') {
                r++;
                if(g < r) {
                    ok = false;
                }
            }
        }

        if(r != g) ok = false;

        if(ok) {
            cout << "possible" << endl;
        } else {
            cout << "impossible" << endl;
        }

    }

}
0