結果

問題 No.345 最小チワワ問題
ユーザー funakoshifunakoshi
提出日時 2019-08-20 10:45:40
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,142 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 30,592 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 02:00:12
合計ジャッジ時間 1,063 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 AC 1 ms
5,376 KB
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 AC 1 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
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=0,minlen=999;
    bool fw=false;
    scanf("%s",str);
    for (int i = 0; i < strlen(str) - 1; i++)
        {
            
            if (str[i] == 'c')
            {
                len++;
                fw = true;                
            }
            else
            {
                continue;                
            }
            for (int j = i + 1; j < strlen(str); j++)
            {
                
                if (str[j] == 'w' && fw == true)
                {
                    fw = false;
                }
                else if (str[j] == 'w' && fw == false)
                {
                    len++;
                    if (minlen > len)
                    {
                        minlen = len;
                    }
                    len = 0;
                    break;
                    }
                    len++;
                }


            }
    if(minlen!=999)
    {
        printf("%d",len);
    }
    else
    {
        printf("-1");
    }
    
}
0