結果

問題 No.154 市バス
ユーザー tatsukawatatsukawa
提出日時 2016-07-22 19:25:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 160,564 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:53:19
合計ジャッジ時間 2,228 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,812 KB
testcase_01 AC 9 ms
6,940 KB
testcase_02 AC 9 ms
6,940 KB
testcase_03 AC 9 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 6 ms
6,940 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
        bool ok = true;
        cin >> s;

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

        if(r != g) ok = false;

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

    }

}
0