結果

問題 No.345 最小チワワ問題
ユーザー kapokapo
提出日時 2016-05-03 18:00:12
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 21,184 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 03:50:59
合計ジャッジ時間 1,533 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 0 ms
4,348 KB
testcase_04 AC 0 ms
4,348 KB
testcase_05 AC 0 ms
4,348 KB
testcase_06 AC 0 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 0 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 0 ms
4,348 KB
testcase_12 AC 0 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 0 ms
4,348 KB
testcase_18 AC 0 ms
4,348 KB
testcase_19 AC 0 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 0 ms
4,348 KB
testcase_22 AC 0 ms
4,348 KB
testcase_23 AC 0 ms
4,348 KB
testcase_24 AC 0 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 0 ms
4,348 KB
testcase_27 AC 0 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 0 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 0 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:17: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[101]’ [-Wformat=]
    7 |         scanf("%s", &s);
      |                ~^   ~~
      |                 |   |
      |                 |   char (*)[101]
      |                 char *
main.c:9:26: warning: comparison between pointer and integer
    9 |         for( i = 0; s[i] != NULL; i++) {
      |                          ^~
main.c:12:44: warning: comparison between pointer and integer
   12 |                         for( j = i+1; s[j] != NULL && c != 2; j++) {
      |                                            ^~
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%s", &s);
      |         ^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void)
{
	int i, j, m = 100, c;
	char s[101] = {};
	scanf("%s", &s);

	for( i = 0; s[i] != NULL; i++) {
		if(s[i] == 'c') {
			c = 0;
			for( j = i+1; s[j] != NULL && c != 2; j++) {
				if( s[j] == 'w' ) c++;
				if( c == 2 && j-i+1 < m) m = j-i+1;
			}
		}
	}
	if( m == 100 ) {
		printf("-1\n");
		return 0;
	}
	printf("%d\n", m);
	return 0;
}
0