結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2020-03-06 19:42:34 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 502 bytes |
コンパイル時間 | 392 ms |
コンパイル使用メモリ | 23,424 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 03:23:26 |
合計ジャッジ時間 | 1,267 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | scanf("%s",str); | ~~~~~^~~~~~~~~~
ソースコード
#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;}