This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |