結果

問題 No.154 市バス
ユーザー 古寺いろは
提出日時 2015-03-27 01:12:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 1,181 ms
コンパイル使用メモリ 159,956 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 07:14:24
合計ジャッジ時間 2,080 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;


int main() {
	int N;
	cin >> N;
	for (int t = 0; t < N; t++)
	{
		string S;
		cin >> S;

		vector<int> count(3);
		bool flag = true;
		for (int i = S.size() - 1; i >= 0; i--)
		{
			int r = 0;
			if (S[i] == 'G') r = 1;
			if (S[i] == 'R') r = 2;
			count[r]++;
			if (count[0] != 0 && count[1] == 0) flag = false;
			if (count[0] != 0 && count[2] == 0) flag = false;
			if (count[2] < count[1]) flag = false;
		}
		if (count[2] != count[1]) flag = false;
		if (count[0] < count[1]) flag = false;

		if (flag) cout << "possible" << endl;
		else cout << "impossible" << endl;
	}
}

0