結果

問題 No.154 市バス
ユーザー erieri
提出日時 2015-07-21 04:10:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 612 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 57,196 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 08:40:54
合計ジャッジ時間 1,118 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;
bool possible(string s){
	int w, g, r, lw, lg, lr;
	w = g = r = 0;
	lw, lg, lr = -1;
	for (char c:s){
		switch (c){
		case 'W':
			w++; lw = c;
			break;
		case 'G':
			if (w == 0) return false;
			w--; g++; lg = c;
			break;
		case 'R':
			if (g == 0) return false;
			g--; r++; lr = c;
			break;
		}
	}
	if (g != 0 || r == 0) return false;
	if (lw < lg && lg < lr) return true;
	return false;
}
int main(){
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		string s; cin >> s;
		cout << (possible(s) ? "possible" : "impossible") << endl;
	}
	return 0;
}
0