結果

問題 No.154 市バス
ユーザー Iruyan_Zak
提出日時 2016-06-19 15:48:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 65,024 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 08:31:17
合計ジャッジ時間 1,293 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

string solve(string str){
    # define OK "possible"
    # define NG "impossible"
    int n = str.size(), w=0, g=0;
    if(str[n-1] != 'R') return NG;
    for(int i=0; i<n; ++i){
        char c = str[i];
             if(c == 'W') ++w;
        else if(c == 'G') ++g;
        else if((--w)<0 || (--g)<0) return NG;
    }
    if(g != 0) return NG;
    return OK;

}

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