結果

問題 No.345 最小チワワ問題
ユーザー sasa
提出日時 2025-03-06 16:49:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 28,288 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2025-03-06 16:49:48
合計ジャッジ時間 2,195 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%s", str);
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<string.h>
int main()
{
	char str[102];
	scanf("%s", str);
	int i, j, k, n = strlen(str);
	int ans = 4649;
	for (i = 0; i < n - 2; i++){
		for (j = i + 1; j < n - 1; j++){
			for (k = j + 1; k < n; k++){
				if (str[i] == 'c' && str[j] == 'w' && str[k] == 'w'){
					if (ans > k - i + 1){
						ans = k - i + 1;
					}
				}
			}
		}
	}	
	if (ans > 100){
		ans = -1;
	}
	printf("%d\n", ans);
}
0