結果

問題 No.154 市バス
ユーザー PicklesSuperiorPicklesSuperior
提出日時 2019-03-14 12:44:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,664 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 62,316 KB
実行使用メモリ 4,704 KB
最終ジャッジ日時 2023-09-08 15:09:38
合計ジャッジ時間 1,446 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){

    int T;
    vector<string> bus_memos;
    string row;

    cin >> T;
    for(int i=0;i<T;i++){
        cin >> row;
        bus_memos.push_back(row);
    }
/**
    for(int i=0;i<T;i++){
        cout<< bus_memos[i] <<endl;
        for(int j=0;j<bus_memos[i].size();j++){
            cout<< bus_memos[i][j] <<endl;
        }
    }
**/
    for(int i=0;i<T;i++){
        int T_memo = bus_memos[i].size();
        int white=0,green=0,red=0,bus_count=1;
        bool next=false;
        bool judge=true;
        for(int j=0;j<T_memo;j++){
            switch(bus_memos[i][j]){
                case 'W':
                    white+=1;
                    if(next==true){
                        bus_count+=1;
                        next=false;
                    }
                    break;
                case 'G':
                    green+=1;
                    if(next==true){
                        bus_count+=1;
                    }else{
                        next=true;
                    }
                    break;
                case 'R':
                    red+=1;
                    next=true;
                    break;
            }
            if(green<red){
                judge=false;
                break;
            }
        }
        if(!(red==bus_count) || bus_count>white) judge=false;
        //cout<< "whit:" << white << " green:" << green << " red:" << red << " bus_c:"<< bus_count << endl;
        if(judge){
            cout << "possible" << endl;
        }else{
            cout << "impossible" << endl;
        }
    }

    return 0;
}
0