結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2018-02-22 16:51:17 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 432 bytes |
コンパイル時間 | 509 ms |
コンパイル使用メモリ | 21,888 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 21:00:37 |
合計ジャッジ時間 | 1,196 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 21 |
コンパイルメッセージ
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; } } if(strlen(s)-t==4){ break; } } 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; }