제출 #148507

#제출 시각아이디문제언어결과실행 시간메모리
148507TLEWA맞 (#200)HicCup (FXCUP4_hiccup)C++17
0 / 100
21 ms3456 KiB
#include "hiccup.h"
#include<algorithm>
int HicCup(std::string S) {
    int H=0,C=0,A=0;
    int cnt;
    int N=S.size();
    int flag=0;
    for(int i=0;i<N;i++){
        if(!flag&&S[i]=='H')flag=1;
        if(S[i]=='H'&&i<N-1&&S[i+1]=='!'){
            return -1;
        }
        if(S[i]=='H')H++;
        if(!flag&&S[i]=='C'){
            return -1;
        }
        if(S[i]=='C'){
            C++;
            cnt=0;
        }
        if(flag&&S[i]=='!'){
            A++;
            cnt++;
        }
    }
    if(H!=C)return -1;
    return std::min(A/H,cnt);
}

컴파일 시 표준 에러 (stderr) 메시지

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:5:9: warning: 'cnt' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int cnt;
         ^~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…