이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
bool can (int L) {
vector<int> S;
S.push_back(-1);
for(int i=0;i<n;i++) {
if(s[i] == 'H') S.push_back(-1);
if(s[i] == 'C') {
if(S.empty() || S.back() >= 0) return false;
S.pop_back();
S.push_back(1);
}
if(s[i] == '!') {
if(S.empty() || (-2 < S.back() && S.back() < 0)) return false;
if(S.back() > 0) S.back()++;
}
if(S.back() == L+1) {
S.pop_back();
if(S.empty()) return false;
if(S.back() < 0) S.back() = -2;
}
}
return S.size() == 1 && S[0] < 0;
}
int HicCup(string _) {
n = _.size();
s = _;
int S = -1, E = n;
while(S<E) {
int M = (S+E)>>1;
can(M+1) ? S = M+1 : E = M;
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |