結果

問題 No.345 最小チワワ問題
ユーザー zazaboonzazaboon
提出日時 2016-03-08 04:10:15
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 22,056 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 03:43:56
合計ジャッジ時間 1,232 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#define JOGEN 100
#include <stdlib.h>

int int_sort(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}
int main (void)
{
	int i, j, nagasa[JOGEN], hantei = 0;
	char mojiretsu[(JOGEN + 1)]; 
	scanf("%s", &mojiretsu);
	for(i = 0; i < JOGEN; i++)
	{
		nagasa[i] = 0;
		for(j = i; (j < JOGEN) && (hantei < 2); j++)
		{
			if(mojiretsu[i] != 'c') 
			{
				break;
			}
			if(mojiretsu[j] == 'w')
			{
				hantei++;
			}
			nagasa[i]++;
		}
		if(hantei < 2)
		{
			nagasa[i] = 9999;
		}
		hantei = 0;
	}
	qsort(nagasa, JOGEN, sizeof(int), int_sort);
	
	if(nagasa[0] < JOGEN)
	{
		printf("%d\n", nagasa[0]);
	}
	else 
	{
		printf("-1\n");
	}
	return 0;
}
0