| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 151588 | leduykhongngu | HicCup (FXCUP4_hiccup) | C++17 | 3 ms | 508 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <iostream>
#include <cstring>
#include <stack>
#include <cassert>
#include <vector>
#include <algorithm>
using namespace std;
string S = "";
int n;
int pre[1000005], sum[1000005];
vector<int> End;
bool Check(int lim)
{
    int last = S.length() - 1;
    int cnt = 0;
    for (int R : End) {
        cnt += sum[last] - sum[R - 1];
        if (cnt < lim) return false;
        cnt -= lim;
        last = R;
    }
    return true;
}
int HicCup(std::string tmp)
{
    S = tmp;
    stack<int> st;
    for (int i = 0; i < tmp.length(); ++i) {
        sum[i] = sum[i-1];
        if (S[i] == '!') {
            if (i > 0 && S[i-1] == 'H') return false; 
            ++sum[i];
            continue;
        }
        if (S[i] == 'H') {
            st.push(i);
        }
        else {
            assert(S[i] == 'C');
            int L = st.top();
            pre[i] = L;
            st.pop();
            End.push_back(i);
        }
    }
    if (st.size()) return -1;
    reverse(End.begin(), End.end());
    int lef = 0, rig = S.length(), ans = -1;
    while (lef <= rig)
    {
        int mid = (lef + rig)/2;
        if (Check(mid))
        {
            ans = max(ans, mid);
            lef = mid + 1;
        }
        else rig = mid - 1;
    }
    return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
