結果

問題 No.154 市バス
コンテスト
ユーザー やまじゅん
提出日時 2017-06-30 15:38:38
言語 C90
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 557 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 181 ms
コンパイル使用メモリ 38,256 KB
最終ジャッジ日時 2026-02-24 00:47:36
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

int main(void)
{
	int times, i, j, white, green, red;
	char bus[1001];

	scanf("%d", &times);

	for (i = 0;i < times;i++) {
		scanf("%s", bus);

		j = white = green = red = 0;
		while (bus[j]!='\0') {
			if (bus[j] == 'W')white++;
			if (bus[j] == 'G')green++;
			if (bus[j] == 'R')red++;
			if ((white < green) || (green < red) || (white < red)) {
				goto IMPOSSIBLE;
			}
			j++;
		}

		if (green != red) {
			goto IMPOSSIBLE;
		}

		printf("possible\n");
		continue;
	IMPOSSIBLE:
		printf("impossible\n");
		continue;
	}
	return 0;
}
0