結果

問題 No.154 市バス
ユーザー Mcpu3Mcpu3
提出日時 2018-12-05 21:12:04
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 28,380 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 11:26:32
合計ジャッジ時間 1,019 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int main(void)
{
	char S[1001];
	int T, length, tmp1, tmp2, i, j;
	scanf("%d", &T);
	for (i = 0; i < T; ++i) {
		scanf("%s", S);
		length = strlen(S);
		tmp1 = 0;
		tmp2 = 0;
		for (j = 0; j < length; ++j) {
			if (S[j] == 'W') ++tmp1;
			else if (S[j] == 'G') {
				if (tmp1 == 0) break;
				--tmp1;
				++tmp2;
			}	
			else {
				if (tmp2 == 0) break;
				--tmp2;
			}
		}
		if (j != length || tmp1 || tmp2) puts("impossible");
		else puts("possible");
	}
	return 0;
}
0