답안 #148554

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148554 2019-09-01T04:39:07 Z TLEWA맞(#3625, H_Squad, sungjune222, str0ct) HicCup (FXCUP4_hiccup) C++17
24 / 100
23 ms 3328 KB
#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++;
            if(C>H)return -1;
            cnt=0;
        }
        if(!flag&&S[i]=='!'){
            return -1;
        }
        if(flag&&S[i]=='!'){
            A++;
            cnt++;
        }
    }
    if(H!=C)return -1;
    return std::min(A/H,cnt);
}

Compilation message

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;
         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 20 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 14 ms 3328 KB Output is correct
8 Correct 23 ms 3328 KB Output is correct
9 Correct 21 ms 3328 KB Output is correct
10 Correct 14 ms 3328 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 20 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 14 ms 3328 KB Output is correct
8 Correct 23 ms 3328 KB Output is correct
9 Correct 21 ms 3328 KB Output is correct
10 Correct 14 ms 3328 KB Output is correct
11 Correct 20 ms 3328 KB Output is correct
12 Correct 14 ms 3200 KB Output is correct
13 Correct 15 ms 3200 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 13 ms 3328 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 592 KB Output is correct
19 Correct 16 ms 3328 KB Output is correct
20 Incorrect 15 ms 3328 KB Output isn't correct
21 Halted 0 ms 0 KB -