# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
148398 |
2019-09-01T04:17:23 Z |
Seishun Buta Yarou wa Yumemiru Shoujo no Yume wo Minai(#3781, zscoder, tmwilliamlin168) |
HicCup (FXCUP4_hiccup) |
C++17 |
|
31 ms |
7296 KB |
#include "hiccup.h"
#include <bits/stdc++.h>
using namespace std;
int a[1000000];
bool chk(string &s, int l, int r, int x, int b=0) {
if(l>r)
return 1;
while(s[r]=='!') {
--r;
++b;
}
b-=x;
if(b<0)
return 0;
return chk(s, a[r]+1, r-1, x)&&chk(s, l, a[r]-1, x, b);
}
int HicCup(string s) {
int n=s.size();
//check correctness
if(s[0]=='!')
return -1;
for(int i=0; i+1<n; ++i)
if(s[i]=='H'&&s[i+1]=='!')
return -1;
//bracket matching
vector<int> t;
for(int i=0; i<n; ++i) {
if(s[i]=='H')
t.push_back(i);
else if(s[i]=='C') {
if(t.empty())
return -1;
a[i]=t.back();
t.pop_back();
}
}
if(t.size())
return -1;
int lb=0, rb=n;
while(lb<rb) {
int mb=(lb+rb+1)/2;
if(chk(s, 0, n-1, mb))
lb=mb;
else
rb=mb-1;
}
return lb;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
640 KB |
Output is correct |
5 |
Correct |
29 ms |
7160 KB |
Output is correct |
6 |
Correct |
21 ms |
3328 KB |
Output is correct |
7 |
Correct |
21 ms |
3328 KB |
Output is correct |
8 |
Correct |
31 ms |
7160 KB |
Output is correct |
9 |
Correct |
30 ms |
7296 KB |
Output is correct |
10 |
Correct |
19 ms |
3328 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
640 KB |
Output is correct |
5 |
Correct |
29 ms |
7160 KB |
Output is correct |
6 |
Correct |
21 ms |
3328 KB |
Output is correct |
7 |
Correct |
21 ms |
3328 KB |
Output is correct |
8 |
Correct |
31 ms |
7160 KB |
Output is correct |
9 |
Correct |
30 ms |
7296 KB |
Output is correct |
10 |
Correct |
19 ms |
3328 KB |
Output is correct |
11 |
Correct |
17 ms |
3144 KB |
Output is correct |
12 |
Correct |
15 ms |
3328 KB |
Output is correct |
13 |
Correct |
12 ms |
3328 KB |
Output is correct |
14 |
Correct |
5 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 |
22 ms |
7168 KB |
Output is correct |
20 |
Correct |
22 ms |
7168 KB |
Output is correct |
21 |
Correct |
23 ms |
4992 KB |
Output is correct |
22 |
Correct |
22 ms |
3200 KB |
Output is correct |
23 |
Correct |
27 ms |
3328 KB |
Output is correct |
24 |
Correct |
21 ms |
7296 KB |
Output is correct |
25 |
Correct |
28 ms |
7040 KB |
Output is correct |
26 |
Correct |
24 ms |
7296 KB |
Output is correct |
27 |
Correct |
19 ms |
5376 KB |
Output is correct |
28 |
Correct |
23 ms |
3584 KB |
Output is correct |
29 |
Correct |
24 ms |
3328 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
7 ms |
640 KB |
Output is correct |
33 |
Correct |
6 ms |
384 KB |
Output is correct |