結果

問題 No.154 市バス
ユーザー mocobtmocobt
提出日時 2018-06-09 20:41:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,050 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 64,824 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 02:22:04
合計ジャッジ時間 1,357 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

auto T=0;

void input(){
    cin >> T;
}

void solve(){
    for(int i=0; i<T; i++){
        string s;
        cin >> s;
        if(s.size()<3){
            cout << "impossible" << endl;
            continue;
        }
        
        auto r_cnt = 0, g_cnt = 0, w_cnt = 0;
        bool ans = true, f = false;
        for(int j=0;j<s.size();j++){
            switch(s[j]){
                case 'R':
                    r_cnt++;
                    break;
                case 'G':
                    f=true;
                    g_cnt++;
                    break;
                case 'W':
                    w_cnt++;
                    f=false;
                    break;
            }

            if(!(w_cnt>=g_cnt&&g_cnt>=r_cnt)){
                ans = false;
                break;
            }
        }
        if(g_cnt!=r_cnt&&!f) ans = false;

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

int main(){
    input();
    solve();
}
0