# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
149178 | 20190901 (#200) | HicCup (FXCUP4_hiccup) | C++17 | 445 ms | 20404 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include <vector>
using namespace std;
bool Check(string str, int mid)
{
vector<pair<char, int>> stk;
int hCnt = 0;
int cCnt = 0;
for (int i = 0; i < str.size(); i++)
{
if (str[i] == 'H')
{
stk.push_back({ 'H', -1 });
hCnt++;
}
else if (str[i] == 'C')
{
if (hCnt > cCnt)
stk.push_back({ 'C', 0 });
else
return false;
cCnt++;
}
else
{
if (stk.empty() || stk.back().first == 'H')
return false;
else
stk.push_back({ '!', stk.back().second + 1 });
}
if (stk.back().second == mid)
{
for (int i = 0; i < mid + 2; i++)
{
if (stk.empty())
return false;
if (stk.back().first == 'C')
cCnt--;
else if (stk.back().first == 'H')
hCnt--;
stk.pop_back();
}
}
}
for (int i = 0; i < stk.size(); i++)
{
if (stk[i].first != '!')
return false;
}
return true;
}
int HicCup(string S)
{
int lo = -1;
int hi = (int)S.size();
while (lo + 1 < hi)
{
int mid = (lo + hi) >> 1;
if (Check(S, mid))
{
lo = mid;
}
else
{
hi = mid;
}
}
return lo;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |