結果

問題 No.154 市バス
ユーザー hirakich1048576hirakich1048576
提出日時 2016-07-10 01:22:14
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 748 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:50:23
合計ジャッジ時間 1,032 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define N_MAX 1000

char s[N_MAX + 1];
char t[N_MAX + 1];

int answer;

int i, j, n;

int abs(int x){
	return (x > 0) ? x : -x;
}

int min(int x, int y){
	return (x > y) ? y : x;
}

int comp (int *x, int *y) {
	return *y - *x;
}

int solve(){

	char *p;
	int w, g, r;
	w = g = r = 0;

	for (p = s; *p; p++) {
		switch (*p) {
		case 'W':
			w++;
			break;
		case 'G':
			g++;
			if (g > w) return 0;
			break;
		case 'R':
			r++;
			if (r > g) return 0;
			break;
		}
	}

	if (g == r && g) {
		return 2;
	} else {
		return 0;
	}

}

int main(void){

	const char imp[] = "impossible";

	scanf("%d", &n);

	for (j = 0; j < n; j++) {
		scanf("%s", s);
		puts(imp+solve());
	}

	return 0;
}


0