Submission #229249

# Submission time Handle Problem Language Result Execution time Memory
229249 2020-05-03T23:11:48 Z 534351 HicCup (FXCUP4_hiccup) C++17
24 / 100
23 ms 8448 KB
#include "hiccup.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const int MAXN = 1000013;

int N, M, K;
pii pos[MAXN];
int val[MAXN];
int ans = MAXN;

int HicCup(string str)
{
    N = SZ(str);
	if (str[0] == '!') return -1;
    vi stk;
    FORD(i, N, 0)
    {
        char c = str[i];
        if (c == '!')
        {
            if (str[i - 1] == 'H')
            {
                return -1;
            }
            K++;
        }
        else if (c == 'H')
        {
            if (stk.empty()) return -1;
            val[i] = stk.back();
            stk.pop_back();
        }
        else if (c == 'C')
        {
            val[i] = M;
            M++;
            stk.PB(M);
            ckmin(ans, K / M);
        }
        else return -1;
    }
    if (!stk.empty())
    {
        return -1;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
5 Correct 23 ms 8448 KB Output is correct
6 Correct 12 ms 4352 KB Output is correct
7 Correct 12 ms 4224 KB Output is correct
8 Correct 20 ms 8192 KB Output is correct
9 Correct 21 ms 8192 KB Output is correct
10 Correct 12 ms 4352 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
5 Correct 23 ms 8448 KB Output is correct
6 Correct 12 ms 4352 KB Output is correct
7 Correct 12 ms 4224 KB Output is correct
8 Correct 20 ms 8192 KB Output is correct
9 Correct 21 ms 8192 KB Output is correct
10 Correct 12 ms 4352 KB Output is correct
11 Correct 12 ms 4352 KB Output is correct
12 Correct 13 ms 4992 KB Output is correct
13 Correct 14 ms 5632 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 16 ms 8192 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 640 KB Output is correct
19 Correct 16 ms 8064 KB Output is correct
20 Incorrect 16 ms 8320 KB Output isn't correct
21 Halted 0 ms 0 KB -