結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
Haijinn
|
| 提出日時 | 2018-02-22 16:47:38 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 396 bytes |
| コンパイル時間 | 629 ms |
| コンパイル使用メモリ | 21,760 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-01 20:52:49 |
| 合計ジャッジ時間 | 1,208 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 20 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:11:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%s",s);
| ^~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
char s[101];
int i;
int x=0;
int z=0;
int t=0;
scanf("%s",s);
for(i=0;i<strlen(s);i++){
if(s[i]=='c'){
if(t<=i){
t=i;
}
}
}
for(i=0;i<strlen(s);i++){
if(s[i]=='w'){
if(z<=i&&t<i){
z=i;
x++;
if(x==2){
break;
}
}
}
}
if(z-t+1>0){
printf("%d\n",z-t+1);
}else{
printf("-1\n");
}
return 0;
}
Haijinn