제출 #149138

#제출 시각아이디문제언어결과실행 시간메모리
149138Cafe Maru (#200)HicCup (FXCUP4_hiccup)C++17
24 / 100
23 ms3328 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()++; } } int e = es.back(); int c = cs.back(); es.pop_back(); cs.pop_back(); if (!es.empty()) return -1; if (e == 0) ans = 0; else ans = min(ans, e/c); 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) {
                        ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...