結果

問題 No.345 最小チワワ問題
ユーザー butsurizuki
提出日時 2016-11-30 16:56:40
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 370 bytes
コンパイル時間 1,249 ms
コンパイル使用メモリ 20,736 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-25 11:55:39
合計ジャッジ時間 1,166 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
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("%s",s);
      |         ^~~~~~~~~~~~~

ソースコード

diff #

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

int main(void){
	int i,j,c,l,m=1000;
	char s[128];
	scanf("%s",s);
	l = strlen(s);
	for(i = 0;i < l;i++){
		if(s[i] != 'c'){continue;}
		c = 0;
		for(j = i+1;j < l;j++){
			if(s[j] == 'w'){c++;}
			if(c == 2){
				if(m > j-i+1){m = j-i+1;}
				break;
			}
		}
	}
	if(m == 1000){printf("-1\n");}else{printf("%d\n",m);}
	return 0;
}
0