結果

問題 No.345 最小チワワ問題
ユーザー FF256grhy
提出日時 2016-03-24 14:20:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 22,144 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 11:41:20
合計ジャッジ時間 982 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%s", s);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int i, j, count, min = 101;
char s[101];

int main(void) {
	scanf("%s", s);
	
	while(s[i] != '\0') {
		if(s[i] == 'c') {
			count = 0;
			j = i;
			while(s[j] != '\0') {
				if(s[j] == 'w') { count++; }
				if(count == 2) {
					min = ( (j - i + 1) < min ? (j - i + 1) : min );
					break;
				}
				j++;
			}
		}
		i++;
	}
	
	printf("%d\n", (min == 101 ? -1 : min));
	
	return 0;
}
0