結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-23 14:36:49 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 443 bytes |
| コンパイル時間 | 94 ms |
| コンパイル使用メモリ | 20,992 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 20:37:28 |
| 合計ジャッジ時間 | 831 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 1 |
コンパイルメッセージ
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]== '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;
}