結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-06 19:42:34 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 502 bytes |
| 記録 | |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 40,192 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-01 13:36:47 |
| 合計ジャッジ時間 | 5,998 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <cstdio>
#include <cstring>
int main(){
char str[101];
scanf("%s",str);
int len=strlen(str),ans=len+1;
for(int p1=0,p2,p3;p1<len;p1++){
if(str[p1]=='c')for(p2=p1+1;p2<len;p2++){
if(str[p2]=='w')for(p3=p2+1;p3<len;p3++){
if(str[p3]=='w'){
if(p3-p1<ans)ans=p3-p1+1;break;
}
}
}
}
if(ans!=len+1)printf("%d\n",ans);
else printf("-1\n");
return 0;
}