結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
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 WA -
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 1 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
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=0,minlen=999;
    bool cin=false;
    bool win=false;
    scanf("%s",str);
    for(int i=0;i<strlen(str)-1;i++)
    {
        if(str[i]=='c')
        {
            cin=true;
            len++;
        }
        else
        {
            continue;
        }
        if(cin==true)
        {
            for(int j=i+1;j<strlen(str);j++)
            {
                if(str[j]=='w'&&win==false)
                {
                    win=true;
                }
                else if(win=true)
                {
                    len++;
                    if(minlen>len)
                    {
                        minlen=len;
                    }
                    len=0;
                    break;
                }
                len++;
            }
        }
        
    }
    if(minlen!=999)
    {
        printf("%d",len);
    }
    else
    {
        printf("-1");
    }
    
}
0