結果

問題 No.154 市バス
ユーザー amtgjwamtgjw
提出日時 2018-06-06 10:16:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 871 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 64,120 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-12 22:41:43
合計ジャッジ時間 1,401 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)
#define PER(i,n)	for(int i=0;i>(n);--i)
#define PERS(i,s,t)	for(int i=(s);i>(t);--i)

#define INF 		2000000007
#define MINF		-200000007
#define MOD			17 	
// 2^20

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

int dp[4912];

int main(){
	int N;cin>>N;

	REP(i,N){
		string str;cin>>str;
		bool flag = true;
		int cntw=0,cntr=0,pm=0	;
		PERS(j,str.size()-1,-1){
			if(str[j]=='R'){cntr++;pm++;}
			else if(str[j]=='G'){pm--;}
			else cntw++;
			if(pm<0) {flag = false;break;}
		}
		if(cntw < cntr) flag = false;
		cout << (flag ? "possible\n" : "impossible\n") ;
	}


	return 0;
}
0