結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2017-03-23 14:02:09 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 504 bytes |
コンパイル時間 | 238 ms |
コンパイル使用メモリ | 20,608 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 20:37:16 |
合計ジャッジ時間 | 1,091 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 12 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%s",s); | ^~~~~~~~~~~~~
ソースコード
#include <stdio.h>#include<string.h>int main(void) {int i,j,min=100,w=0,count=0;char s[100];scanf("%s",s);for(i=0;i<strlen(s);i++){if(s[i]=='c'){count++;for(j=i+1;j<strlen(s);j++){if(s[j]== 'c'){count=0;break;}else if(s[j]== 'w'){count++;w++;if(w==2){w=0;if(min>count){min=count;count=0;break;}}}else count++;}}}printf("%d",(min!=100? min : -1));return 0;}