# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
148472 | 2019-09-01T04:29:59 Z | White Fairy(#3613, wifi) | HicCup (FXCUP4_hiccup) | C++17 | 59 ms | 3328 KB |
#include "hiccup.h" #include <bits/stdc++.h> using namespace std; bool can(string & S, int & it, int x) { int cnt = 0, need = 0; while (it < S.size()) { if (cnt > 0 && need == 0) { --cnt; need = x; } char ch = S[it++]; if (ch == '!') { if (need > 0) { --need; } } else if (ch == 'H') { bool res = can(S, it, x); if (!res) return false; ++cnt; } else { return cnt <= 0 && need <= 0; } } return cnt <= 0 && need <= 0; } int HicCup(std::string S) { int N = S.size(); int open = 0; for (int i = 0; i < N; ++i) { if (S[i] == 'H') ++open; else if (S[i] == 'C') --open; if (open < 0) return -1; } if (open != 0) return -1; if (S[0] == '!') return -1; for (int i = 0; i + 1 < N; ++i) { if (S[i] == 'H' && S[i+1] == '!') return -1; } int low = 0, hi = N; while (low < hi) { int mid = (low + hi + 1) >> 1; int it = 0; if (can(S, it, mid)) low = mid; else hi = mid-1; } return low; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 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 | 7 ms | 512 KB | Output is correct |
5 | Correct | 25 ms | 3328 KB | Output is correct |
6 | Correct | 12 ms | 3328 KB | Output is correct |
7 | Correct | 12 ms | 3328 KB | Output is correct |
8 | Correct | 25 ms | 3328 KB | Output is correct |
9 | Correct | 26 ms | 3328 KB | Output is correct |
10 | Correct | 13 ms | 3328 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 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 | 7 ms | 512 KB | Output is correct |
5 | Correct | 25 ms | 3328 KB | Output is correct |
6 | Correct | 12 ms | 3328 KB | Output is correct |
7 | Correct | 12 ms | 3328 KB | Output is correct |
8 | Correct | 25 ms | 3328 KB | Output is correct |
9 | Correct | 26 ms | 3328 KB | Output is correct |
10 | Correct | 13 ms | 3328 KB | Output is correct |
11 | Correct | 14 ms | 3328 KB | Output is correct |
12 | Correct | 13 ms | 3328 KB | Output is correct |
13 | Correct | 14 ms | 3328 KB | Output is correct |
14 | Correct | 6 ms | 384 KB | Output is correct |
15 | Correct | 14 ms | 3328 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 6 ms | 640 KB | Output is correct |
19 | Correct | 30 ms | 3200 KB | Output is correct |
20 | Correct | 23 ms | 3328 KB | Output is correct |
21 | Correct | 44 ms | 3328 KB | Output is correct |
22 | Correct | 36 ms | 3200 KB | Output is correct |
23 | Correct | 50 ms | 3328 KB | Output is correct |
24 | Correct | 19 ms | 3328 KB | Output is correct |
25 | Correct | 24 ms | 3328 KB | Output is correct |
26 | Correct | 19 ms | 3328 KB | Output is correct |
27 | Correct | 42 ms | 3328 KB | Output is correct |
28 | Correct | 57 ms | 3072 KB | Output is correct |
29 | Correct | 59 ms | 3328 KB | Output is correct |
30 | Correct | 6 ms | 384 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 8 ms | 640 KB | Output is correct |
33 | Correct | 5 ms | 384 KB | Output is correct |