結果

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

テストケース

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

ソースコード

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;
		int numG = 0;
		REP(j, S.length()){
			if(S[j]=='W'){
				numG=0;
				numWG++;
			}else if(S[j]=='G'){
				numWG--;
				numGR++;
				numG++;
			}else{
				numGR--;
			}
			//cout<<numGR<<endl;
			if(numWG<0||numGR<0){
				cout<<"impossible"<<endl;
				flag=true;
				break;
			}
		}
		if(flag){
			continue;
		}
		if(numGR!=0 || numG==0){
			cout<<"impossible"<<endl;
			continue;
		}
		cout<<"possible"<<endl;
	}
	
	return 0;
}
0