結果

問題 No.345 最小チワワ問題
ユーザー funakoshi
提出日時 2019-08-20 10:26:46
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 29,184 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-06 11:44:20
合計ジャッジ時間 980 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
int main(void)
{
    char str[120]="";
    int c=0,w=0,len=-1;
    bool complete=false;
    scanf("%s",str);
    for(int i=0;i<strlen(str);i++)
    {
        if(str[i]=='c')
        {
            c++;
            len=1;
        }
        if(c>0&&str[i]=='w')
        {
            w++;
            if(w==2)
            {
                complete=true;
                break;
            }
        }
        if(c>0)
        {
            len++;
        }
    }
    if(complete==true)
    {
        printf("%d",len);
    }
    else
    {
        printf("-1");
    }
    
}
0