답안 #148394

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148394 2019-09-01T04:17:01 Z Welcome to osu!(#3734, easrui, CodePlatina, jhwest2) HicCup (FXCUP4_hiccup) C++17
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
#include "hiccup.h"
using namespace std;

int HicCup(std::string S)
{
    int cnt = 0;
    for(int i=0; i<S.size(); i++){
        if(S[i]=='H') cnt++;
        else cnt--;
        if(cnt<0){
            cout << -1;
            return 0;
        }
    }
    if(cnt!=0) cout << -1;
    else cout << 0;
}

Compilation message

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:8:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<S.size(); i++){
                  ~^~~~~~~~~
hiccup.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -