# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
149750 |
2019-09-01T07:05:31 Z |
Avengers(#3759, Blagojce) |
HicCup (FXCUP4_hiccup) |
C++17 |
|
40 ms |
15104 KB |
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
#include "hiccup.h"
int HicCup(std::string s) {
int n = s.size();
int cnt[n];
int c = 0;
for(int i = n - 1; i >= 0; i --){
if(s[i] == '!') c ++;
cnt[i] = c;
if(s[i] == 'C') c = 0;
else if(s[i] == 'H' && c > 0) return -1;
}
if(c > 0) return -1;
stack <int> S;
S.push(0);
int sums[n + 1];
int nums[n + 1];
memset(sums, 0, sizeof(sums));
memset(nums, 0, sizeof(nums));
int ANS = n;
fr(i, 0, n){
if(s[i] == 'H') S.push(i + 1);
else if(s[i] == 'C'){
if((int)(S.size()) == 1) return -1;
int id = S.top();
S.pop();
sums[(int)S.top()] += cnt[i];
nums[(int)S.top()] ++;
if(nums[id] > 0) ANS = min(ANS, sums[id] / nums[id]);
}
}
if((int)S.size() > 1)return -1;
if(nums[0] > 0)ANS = min(ANS, sums[0] / nums[0]);
return ANS;
}
/*
int main()
{
cout << HicCup("HC!!HHC!HC!!!C!!!");
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
432 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
896 KB |
Output is correct |
5 |
Correct |
40 ms |
15104 KB |
Output is correct |
6 |
Correct |
24 ms |
15104 KB |
Output is correct |
7 |
Correct |
27 ms |
15096 KB |
Output is correct |
8 |
Correct |
39 ms |
14968 KB |
Output is correct |
9 |
Correct |
40 ms |
15104 KB |
Output is correct |
10 |
Correct |
28 ms |
15104 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
432 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
896 KB |
Output is correct |
5 |
Correct |
40 ms |
15104 KB |
Output is correct |
6 |
Correct |
24 ms |
15104 KB |
Output is correct |
7 |
Correct |
27 ms |
15096 KB |
Output is correct |
8 |
Correct |
39 ms |
14968 KB |
Output is correct |
9 |
Correct |
40 ms |
15104 KB |
Output is correct |
10 |
Correct |
28 ms |
15104 KB |
Output is correct |
11 |
Correct |
14 ms |
3328 KB |
Output is correct |
12 |
Correct |
14 ms |
3968 KB |
Output is correct |
13 |
Correct |
16 ms |
5888 KB |
Output is correct |
14 |
Correct |
6 ms |
392 KB |
Output is correct |
15 |
Correct |
16 ms |
7168 KB |
Output is correct |
16 |
Correct |
6 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 |
Incorrect |
21 ms |
15104 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |