# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
151617 | thebes | HicCup (FXCUP4_hiccup) | C++17 | 2 ms | 256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int MN = 1e6+6;
int lo, hi, i, f, g;
stack<int> st;
stack<char> ch;
int HicCup(string s){
lo = 0, hi = s.size();
while(lo<hi){
int m = (lo+hi)/2;
f = 0; g = 1;
while(st.size()) st.pop();
while(ch.size()) ch.pop();
for(i=0;i<s.size();i++){
if(s[i]=='H'){
st.push(0);
ch.push('H');
}
else if(s[i]=='C'){
if(ch.empty()||ch.top()!='H'){
g = 0;
break;
}
ch.pop();
ch.push('C');
}
else if(s[i]=='!'){
if(ch.empty()&&f) continue;
else if(ch.empty()){g=0; break;}
if(ch.top()=='H'){g=0; break;}
ch.pop();
ch.push('!');
st.top()++;
if(st.top()==m){
f = 1;
st.pop();
ch.pop();
}
}
}
if(!g||ch.size()) hi=m;
else lo=m+1;
}
return lo-1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |