結果

問題 No.154 市バス
ユーザー eve__fuyukieve__fuyuki
提出日時 2018-03-09 13:37:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 55,544 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 23:31:21
合計ジャッジ時間 1,671 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;
int main(){
    int N;
    int Gcheck,Rcheck;
    string input;
    bool flag;
    cin >> N;
    for(int i=0;i<N;i++){
        flag = true;
        Gcheck = 0;
        Rcheck = 0;
        cin >> input;
        for(int j=0;j<input.length();j++){
            if(input[j] == 'W') Gcheck++;
            else if(input[j] == 'R') Rcheck--;
            else{
                Gcheck--;
                Rcheck++;
            }
            if(Gcheck<0 || Rcheck < 0){
                flag = false;
                break;
            }
        }
        if(flag && Rcheck == 0) cout << "possible" << endl;
        else cout << "impossible" << endl;
    }
    return 0;
}
0