結果

問題 No.154 市バス
ユーザー Goryudyuma
提出日時 2015-04-24 12:27:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 700 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 63,476 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 07:20:51
合計ジャッジ時間 1,187 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 5 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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