結果

問題 No.154 市バス
ユーザー furafura
提出日時 2020-05-12 01:43:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 201,168 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 19:10:46
合計ジャッジ時間 4,820 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

void solve(){
	string s; cin>>s;
	while(!s.empty()){
		int n=s.length();

		if(s[n-1]!='R'){
			puts("impossible");
			return;
		}

		vector<bool> del(n);
		del[n-1]=true;
		int phase=0;
		for(int i=n-2;i>=0;i--){
			if(phase==0 && s[i]=='G'){
				del[i]=true;
				phase=1;
			}
			else if(phase==1 && s[i]=='W'){
				del[i]=true;
			}
		}
		if(phase==0){
			puts("impossible");
			return;
		}

		string t;
		rep(i,n) if(!del[i]) t+=s[i];
		s=t;
	}
	puts("possible");
}

int main(){
	int q; scanf("%d",&q); rep(_,q) solve();
	return 0;
}
0