結果

問題 No.154 市バス
ユーザー Iruyan_ZakIruyan_Zak
提出日時 2016-06-19 15:32:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 764 bytes
コンパイル時間 4,746 ms
コンパイル使用メモリ 210,332 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2024-04-21 09:38:18
合計ジャッジ時間 19,062 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<regex>
using namespace std;

string solve(string str){
    # define OK "possible"
    # define NG "impossible"
    regex re("^W+");
    reverse(str.begin(), str.end());
    while(!str.empty()){
        if(str[0] != 'R') return NG;
        str.replace(0, 1, "");
        int g_index = str.find("G");
        if(g_index == -1) return NG;
        str.replace(g_index, 1, "");
        int w_index = str.find("W");
        if(w_index == -1) return NG;
        str.replace(w_index, 1, "");
        str = regex_replace(str, re, "",
        regex_constants::format_first_only);
    }
    return OK;

}

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; ++i){
		string str;
		cin >> str;
        cout << solve(str) << endl;
	}
}
0