結果

問題 No.154 市バス
ユーザー fiord
提出日時 2015-07-07 19:31:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 538 bytes
コンパイル時間 1,437 ms
コンパイル使用メモリ 159,996 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 07:31:22
合計ジャッジ時間 1,903 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 7 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	int t;	cin>>t;
	while(t--){
		string s;	cin>>s;
		int white=0,green=0,red=0;
		bool possible=true;
		for(int i=0;i<(int)s.size();i++){
			if(s[i]=='W')	white++;
			else if(s[i]=='G'){
				green++;
				if(green>white){
					possible=false;
					break;
				}
			}
			else{
				red++;
				if(red>green){
					possible=false;
					break;
				}
			}
		}
		if(red!=green||red==0)	possible=false;
		if(possible)	cout<<"possible"<<endl;
		else 	cout<<"impossible"<<endl;
	}
	return 0;
}
0