結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2016-03-08 04:10:15 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 678 bytes |
コンパイル時間 | 268 ms |
コンパイル使用メモリ | 22,016 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 11:37:28 |
合計ジャッジ時間 | 1,151 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
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); | ^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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; }