結果

問題 No.154 市バス
ユーザー PicklesSuperiorPicklesSuperior
提出日時 2019-03-14 12:54:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,631 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 63,380 KB
実行使用メモリ 4,520 KB
最終ジャッジ日時 2023-09-08 15:25:31
合計ジャッジ時間 1,350 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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;
                    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