結果

問題 No.345 最小チワワ問題
ユーザー funakoshifunakoshi
提出日時 2019-08-20 10:26:46
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 30,080 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 02:00:03
合計ジャッジ時間 1,073 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
5,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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