結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー TEWi_R
提出日時 2017-12-17 17:22:50
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 885 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 163 ms
コンパイル使用メモリ 38,464 KB
最終ジャッジ日時 2026-02-22 00:37:51
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

int findCww(char* s){
    int i = 0;
    int count = -1;

    int isFoundC = 0;
    int isFoundW1 = 0;
    int isFoundW2 = 0;

    for(; i < 100; ++i){
        if(!isFoundW1 && !isFoundW2 && s[i] == 'c'){
            //printf("%d :", i);
            //puts("found C");
            isFoundC = 1;
            count = 1;
        } else if(isFoundC && !isFoundW1 && s[i] == 'w'){
            //printf("%d :", i);
            //puts("found W1");
            isFoundW1 = 1;
        } else if(isFoundC && isFoundW1 && s[i] == 'w'){
            //printf("%d :", i);
            //puts("found W2");
            isFoundW2 = 1;
            
            return count;
        }
        if(isFoundC) count++;
    }
    if(!isFoundW2) return -1;
    return -2;
}

int main(){
    char s[] = "chiwaaaaaaamikawayadeeeeesu";
    // scanf("%s", s);
    printf("%d\n", findCww(s));
}
0