답안 #148742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148742 2019-09-01T05:01:40 Z ummm(#3574, cerberus, aayush9, knandy) HicCup (FXCUP4_hiccup) C++17
100 / 100
125 ms 5296 KB
#include "hiccup.h"
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

bool test(string s, int mid);

int HicCup(std::string s) {
	int n = s.length();
	int lo = 0, hi = n;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (test(s, mid)) {
			lo = mid + 1;
		} else {
			hi = mid - 1;
		}
	}
	return lo - 1;
}

bool test(string s, int mid) {
	int n = s.length();
	stack<char> stk;
	stk.push('#');
	bool del = false;
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == 'H') {
			while (del and stk.top() == '!') {
				stk.pop();
			}
			del = true;
			if (stk.top() != 'C') {
				return false;
			}
			stk.pop();
			for (int j = 0; j < mid; ++j) {
				if (stk.top() != '!') {
					return false;
				}
				stk.pop();
			}
		} else {
			stk.push(s[i]);
			del = false;
		}
	}
	while (del and stk.top() == '!') {
		stk.pop();
	}
	return stk.top() == '#';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 24 ms 4352 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 17 ms 4352 KB Output is correct
8 Correct 28 ms 4352 KB Output is correct
9 Correct 23 ms 4352 KB Output is correct
10 Correct 16 ms 4352 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 24 ms 4352 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 17 ms 4352 KB Output is correct
8 Correct 28 ms 4352 KB Output is correct
9 Correct 23 ms 4352 KB Output is correct
10 Correct 16 ms 4352 KB Output is correct
11 Correct 16 ms 4352 KB Output is correct
12 Correct 17 ms 4396 KB Output is correct
13 Correct 42 ms 5036 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 35 ms 5296 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 7 ms 640 KB Output is correct
19 Correct 35 ms 4908 KB Output is correct
20 Correct 30 ms 5036 KB Output is correct
21 Correct 48 ms 5164 KB Output is correct
22 Correct 72 ms 4668 KB Output is correct
23 Correct 125 ms 5112 KB Output is correct
24 Correct 26 ms 5164 KB Output is correct
25 Correct 25 ms 4316 KB Output is correct
26 Correct 28 ms 4396 KB Output is correct
27 Correct 39 ms 4908 KB Output is correct
28 Correct 74 ms 4552 KB Output is correct
29 Correct 101 ms 4780 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 9 ms 688 KB Output is correct
33 Correct 6 ms 384 KB Output is correct