# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
613140 |
2022-07-30T03:37:17 Z |
ajpiano |
HicCup (FXCUP4_hiccup) |
C++17 |
|
195 ms |
3648 KB |
#include <bits/stdc++.h>
#include "hiccup.h"
using namespace std;
#define f first
#define s second
int HicCup(std::string S) {
int N = S.size();
int hbef = 0;
for(int i = 0; i < N; i++){
if(S[i] == '!'){
if(i == 0 || S[i-1] == 'H') return -1;
}
else if(S[i] == 'H') hbef++;
else{
hbef--;
if(hbef < 0) return -1;
}
}
if(hbef != 0) return -1;
int l = 0, r = 1000000;
while(r-l > 1){
int mid = (l+r)>>1;
vector<pair<int,bool>> stk; //! points. Complete
bool good = 1;
for(int i = 0; i < N; i++){
if(S[i] == 'H'){
stk.push_back({0,0});
}else if(S[i] == 'C'){
while(stk.back().s == 1){
if(stk.back().f < mid) good = 0;
stk.pop_back();
}
stk.back().s = 1;
}else{
if(stk.empty() || stk.back().s == 0) continue;
else stk.back().f++;
if(stk.back().f >= mid) stk.pop_back();
}
}
for(auto &a: stk){
if(a.f < mid) good = 0;
}
if(good) l = mid;
else r = mid;
}
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
416 KB |
Output is correct |
5 |
Correct |
195 ms |
3312 KB |
Output is correct |
6 |
Correct |
8 ms |
3196 KB |
Output is correct |
7 |
Correct |
6 ms |
3156 KB |
Output is correct |
8 |
Correct |
183 ms |
3292 KB |
Output is correct |
9 |
Correct |
185 ms |
3284 KB |
Output is correct |
10 |
Correct |
9 ms |
3140 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
416 KB |
Output is correct |
5 |
Correct |
195 ms |
3312 KB |
Output is correct |
6 |
Correct |
8 ms |
3196 KB |
Output is correct |
7 |
Correct |
6 ms |
3156 KB |
Output is correct |
8 |
Correct |
183 ms |
3292 KB |
Output is correct |
9 |
Correct |
185 ms |
3284 KB |
Output is correct |
10 |
Correct |
9 ms |
3140 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
8 ms |
3156 KB |
Output is correct |
13 |
Correct |
8 ms |
3156 KB |
Output is correct |
14 |
Correct |
6 ms |
3156 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
6 ms |
3156 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
61 ms |
3284 KB |
Output is correct |
21 |
Correct |
71 ms |
3444 KB |
Output is correct |
22 |
Correct |
49 ms |
3236 KB |
Output is correct |
23 |
Correct |
67 ms |
3028 KB |
Output is correct |
24 |
Correct |
72 ms |
3232 KB |
Output is correct |
25 |
Correct |
65 ms |
3648 KB |
Output is correct |
26 |
Correct |
174 ms |
3352 KB |
Output is correct |
27 |
Correct |
73 ms |
3644 KB |
Output is correct |
28 |
Correct |
57 ms |
3236 KB |
Output is correct |
29 |
Correct |
59 ms |
3160 KB |
Output is correct |
30 |
Correct |
65 ms |
3248 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
256 KB |
Output is correct |
33 |
Correct |
6 ms |
468 KB |
Output is correct |