結果

問題 No.154 市バス
ユーザー くれちーくれちー
提出日時 2016-10-06 17:35:35
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 20,608 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:57:34
合計ジャッジ時間 1,054 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,248 KB
testcase_01 AC 10 ms
5,376 KB
testcase_02 AC 11 ms
5,376 KB
testcase_03 AC 10 ms
5,376 KB
testcase_04 AC 9 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 6 ms
5,376 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d", &t);
      |         ^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main() {
	int t, w, g, r, p[1000], i;
	char s;

	scanf("%d", &t);
	getchar();
	for (i = 0; i < t; i++) {
		p[i] = w = g = r = 0;
		while ((s = getchar()) != '\n') {
			if (p[i] != -1) {
				if (s == 'W') w++;
				else if (s == 'G') g++;
				else if (s == 'R') r++;
				if (r > g || g > w) p[i] = -1;
			}
		}
		if (r != g) p[i] = -1;
	}

	for (i = 0; i < t; i++) {
		if (p[i] == -1) printf("impossible\n");
		else printf("possible\n");
	}

	return 0;
}
0