結果

問題 No.154 市バス
ユーザー rodearodea
提出日時 2018-02-23 16:38:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 66,752 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 01:48:30
合計ジャッジ時間 1,411 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<cstring>
using namespace std;

int main()
{
	int t, wcount = 0, gcount = 0, rcount = 0;
	char s[1001];

	cin >> t;

	int miss = 0;
	for (int i = 1; i <= t; i++)
	{
		cin >> s;

		for (int j = strlen(s); j >= 0; j--)
		{
			if (s[j] == 'R')
			{
				rcount++;
			}
			if (s[j] == 'G')
			{
				if (rcount > 0)
				{
					gcount++;
					rcount--;
				}
				else
				{
					miss++;
				}
			}
			if (s[j] == 'W')
			{
				if (gcount > 0)
				{
					gcount--;
					wcount++;
				}
				else if (wcount > 0)
				{
					wcount++;
				}
				else
				{
					miss++;
				}
			}
		}

		if ((rcount != 0 || gcount != 0) || miss > 0)
		{
			cout << "impossible" << endl;
		}
		else
		{
			cout << "possible" << endl;
		}
		miss = 0;
		wcount = 0;
		gcount = 0;
		rcount = 0;
	}
}
0