# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
148627 | 2019-09-01T04:47:53 Z | Ian and 2-bit memory(#3648, percywtc, nhho, ulna) | HicCup (FXCUP4_hiccup) | C++17 | 161 ms | 63224 KB |
#include "hiccup.h" #include <bits/stdc++.h> using namespace std; vector<int> level[1000055]; stack<int> sta; vector<int> have[1000055]; int pt[1000055]; bool diu[1000055]; list<int> l; int res; bool trial(int x, string &S) { int n = S.size(); for (int i = 0; i <= n; i++) pt[i] = 0, diu[i] = true; while (!sta.empty()) sta.pop(); sta.push(n); for (int i = 0; i < n; i++) { if (S[i] == 'H') { sta.push(i); } else if (S[i] == 'C') { sta.pop(); if (pt[sta.top()] < have[sta.top()].size() && have[sta.top()][pt[sta.top()]] < i && diu[sta.top()]) { return false; } diu[sta.top()] = false; while (pt[sta.top()] < have[sta.top()].size() && have[sta.top()][pt[sta.top()]] < i) { pt[sta.top()]++; } pt[sta.top()] += x; if (pt[sta.top()] > have[sta.top()].size()) { return false; } } } return true; } int HicCup(std::string S) { int n = S.size(); for (int i = 0; i <= n; i++) level[i].clear(); for (int i = 0; i <= n; i++) { have[i].clear(); } while (!sta.empty()) sta.pop(); sta.push(n); for (int i = 0; i < n; i++) { if (S[i] == 'H') { sta.push(i); } else if (S[i] == 'C') { if (sta.size() == 1) return -1; sta.pop(); level[sta.top()].push_back(i); } else { have[sta.top()].push_back(i); } } if (sta.size() != 1) return -1; int lb = -1, ub = n + 1; while (ub - lb > 1) { int mid = (ub + lb) >> 1; if (trial(mid, S)) lb = mid; else ub = mid; } return lb; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 47360 KB | Output is correct |
2 | Correct | 36 ms | 47352 KB | Output is correct |
3 | Correct | 36 ms | 47360 KB | Output is correct |
4 | Correct | 39 ms | 48000 KB | Output is correct |
5 | Correct | 128 ms | 63096 KB | Output is correct |
6 | Correct | 49 ms | 50296 KB | Output is correct |
7 | Correct | 51 ms | 50176 KB | Output is correct |
8 | Correct | 134 ms | 63224 KB | Output is correct |
9 | Correct | 143 ms | 63224 KB | Output is correct |
10 | Correct | 47 ms | 50304 KB | Output is correct |
11 | Correct | 34 ms | 47224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 47360 KB | Output is correct |
2 | Correct | 36 ms | 47352 KB | Output is correct |
3 | Correct | 36 ms | 47360 KB | Output is correct |
4 | Correct | 39 ms | 48000 KB | Output is correct |
5 | Correct | 128 ms | 63096 KB | Output is correct |
6 | Correct | 49 ms | 50296 KB | Output is correct |
7 | Correct | 51 ms | 50176 KB | Output is correct |
8 | Correct | 134 ms | 63224 KB | Output is correct |
9 | Correct | 143 ms | 63224 KB | Output is correct |
10 | Correct | 47 ms | 50304 KB | Output is correct |
11 | Correct | 57 ms | 51576 KB | Output is correct |
12 | Correct | 55 ms | 52084 KB | Output is correct |
13 | Correct | 51 ms | 50940 KB | Output is correct |
14 | Correct | 37 ms | 47104 KB | Output is correct |
15 | Correct | 104 ms | 61028 KB | Output is correct |
16 | Correct | 33 ms | 47360 KB | Output is correct |
17 | Correct | 36 ms | 47352 KB | Output is correct |
18 | Correct | 37 ms | 47736 KB | Output is correct |
19 | Correct | 133 ms | 59252 KB | Output is correct |
20 | Correct | 124 ms | 59368 KB | Output is correct |
21 | Correct | 147 ms | 59236 KB | Output is correct |
22 | Correct | 128 ms | 58596 KB | Output is correct |
23 | Correct | 153 ms | 59236 KB | Output is correct |
24 | Correct | 120 ms | 59236 KB | Output is correct |
25 | Correct | 142 ms | 61944 KB | Output is correct |
26 | Correct | 127 ms | 60012 KB | Output is correct |
27 | Correct | 161 ms | 59492 KB | Output is correct |
28 | Correct | 140 ms | 58852 KB | Output is correct |
29 | Correct | 156 ms | 59236 KB | Output is correct |
30 | Correct | 36 ms | 47360 KB | Output is correct |
31 | Correct | 36 ms | 47360 KB | Output is correct |
32 | Correct | 38 ms | 48376 KB | Output is correct |
33 | Correct | 34 ms | 47224 KB | Output is correct |