結果
| 問題 | 
                            No.154 市バス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             furuya1223
                         | 
                    
| 提出日時 | 2016-12-03 19:59:20 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 841 bytes | 
| コンパイル時間 | 1,421 ms | 
| コンパイル使用メモリ | 167,800 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-13 08:47:57 | 
| 合計ジャッジ時間 | 2,293 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | AC * 7 WA * 1 | 
ソースコード
#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'){
				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;
}
            
            
            
        
            
furuya1223