제출 #149112

#제출 시각아이디문제언어결과실행 시간메모리
149112Cafe Maru (#200)HicCup (FXCUP4_hiccup)C++17
24 / 100
24 ms3456 KiB
#include "hiccup.h"
#include<bits/stdc++.h>
using namespace std;

int HicCup(std::string S) {
	int N = S.size();
    int ans = 1111111;
    vector<int> es, cs;
    es.push_back(0);
    cs.push_back(0);
    for(int i=N-1;i>=0;i--) {
        if (S[i] == 'H') {
            int e = es.back();
            int c = cs.back();
            es.pop_back();
            cs.pop_back();
            if (es.empty()) return -1;
            if(e > 0 && c == 0) {
                return -1;
            } else if (e == 0 && c == 0) {
                continue;
            } else if (e == 0 & c > 0) {
                ans = 0;
            } else {
                int t = e/c;
                ans = min(ans, t);
            }
        } else if (S[i] == 'C') {
            cs.back()++;
            es.push_back(0);
            cs.push_back(0);
        } else {
            es.back()++;
        }
    }
    if (ans == 1111111) ans = 0;

	return ans;
}

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

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:22:26: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
             } else if (e == 0 & c > 0) {
                        ~~^~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…