# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
148954 | 서울대학교 연구공원 944동 삼성전자서울대연구소 (#200) | HicCup (FXCUP4_hiccup) | C++17 | 6 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
bool check(ll m, std::string S)
{
vector<ll> L;
L.push_back(0);
int flag = 1;
for(char c : S){
if(c == 'H'){
L.emplace_back(0);
flag = true;
}
if(c == 'C'){
if(L.back() > 0) return false;
L.pop_back();
L.back() += m;
flag = false;
}
if(c == '!'){
if(flag) return false;
L.back() -= 1;
}
}
if(L.back() > 0) return false;
return true;
}
int HicCup(std::string S) {
ll s = 0, e = S.size(), m;
while(s <= e){
ll m = (s+e) / 2;
if(check(m, S)) s = m+1;
else e = m-1;
}swap(s, e);
return s == S.size()? -1 : s;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |