結果

問題 No.154 市バス
ユーザー furuya1223furuya1223
提出日時 2016-12-03 19:44:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 162,944 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 10:01:13
合計ジャッジ時間 2,752 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
//#include <iostream>
//#include <cstdio>

#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 2000000000

typedef long long ll;
typedef unsigned long long ull;
//typedef Pair<int,int> P;

using namespace std;

int main(void){
	int T;
	cin >> T;
	REP(i,T){
		string S;
		cin >> S;
		int numWG = 0;
		int numGR = 0;
		bool flag = false;
		REP(j, S.length()){
			if(S[j]=='W'){
				numWG++;
			}else if(S[j]=='G'){
				numWG--;
				numGR++;
			}else{
				numGR--;
			}
			//cout<<numGR<<endl;
			if(numWG<0||numGR<0){
				cout<<"impossible"<<endl;
				flag=true;
				break;
			}
		}
		if(flag){
			continue;
		}
		if(numGR!=0){
			cout<<"impossible"<<endl;
			continue;
		}
		cout<<"possible"<<endl;
	}
	
	return 0;
}
0