結果

問題 No.154 市バス
ユーザー GoryudyumaGoryudyuma
提出日時 2015-04-24 12:27:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 700 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 64,476 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 08:30:01
合計ジャッジ時間 1,175 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using namespace std;

int main()
{
	string str;
	int N;
	cin >> N;
	for (size_t i = 0; i < N; i++)
	{
		cin >> str;
		vector<int >data;
		data.resize(3);
		bool f = 1;
		for (auto x : str)
		{
			if (x == 'W')
			{
				data[0]++;
			} else if (x == 'G')
			{
				if (data[0])
				{
					data[1]++;
				} else
				{
					f = 0;
				}
			} else if (x == 'R')
			{
				if (data[0] && data[1])
				{
					data[0]--;
					data[1]--;
				} else
				{
					f = 0;
				}
			}
		}
		if (*str.rbegin() == 'W' || *str.rbegin() == 'G')
		{
			f = 0;
		}
		cout << (f ? "possible":"impossible") << endl;
		data.clear();
	}
	return 0;
}
0