# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
613084 | 2022-07-30T03:19:40 Z | penguinhacker | HicCup (FXCUP4_hiccup) | C++17 | 99 ms | 34856 KB |
#include "hiccup.h" #include <bits/stdc++.h> using namespace std; const int mxN=1e6+2; int n=1, cnt[mxN], ans=69696969; stack<int> stk; vector<int> adj[mxN]; void dfs(int u=0) { for (int v : adj[u]) dfs(v); reverse(adj[u].begin(), adj[u].end()); int cur=0; for (int i=0; i<adj[u].size(); ++i) { cur+=cnt[adj[u][i]]; ans=min(ans, cur/(i+1)); } } int HicCup(string s) { stk.push(0); for (int i=0; i<s.size(); ++i) if (s[i]=='!'&&(!i||s[i-1]=='H')) return -1; for (int i=0; i<s.size(); ++i) { if (s[i]=='H') { adj[stk.top()].push_back(n); stk.push(n++); } else if (s[i]=='C') { if (stk.size()==1) return -1; for (; i+1<s.size()&&s[i+1]=='!'; ++i, ++cnt[stk.top()]); stk.pop(); } } if (stk.size()!=1||n==1) return -1; dfs(); return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 23780 KB | Output is correct |
2 | Correct | 22 ms | 23692 KB | Output is correct |
3 | Correct | 20 ms | 23716 KB | Output is correct |
4 | Correct | 21 ms | 24188 KB | Output is correct |
5 | Correct | 93 ms | 34848 KB | Output is correct |
6 | Correct | 29 ms | 26708 KB | Output is correct |
7 | Correct | 25 ms | 26708 KB | Output is correct |
8 | Correct | 82 ms | 34780 KB | Output is correct |
9 | Correct | 99 ms | 34856 KB | Output is correct |
10 | Correct | 27 ms | 26708 KB | Output is correct |
11 | Correct | 20 ms | 23728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 23780 KB | Output is correct |
2 | Correct | 22 ms | 23692 KB | Output is correct |
3 | Correct | 20 ms | 23716 KB | Output is correct |
4 | Correct | 21 ms | 24188 KB | Output is correct |
5 | Correct | 93 ms | 34848 KB | Output is correct |
6 | Correct | 29 ms | 26708 KB | Output is correct |
7 | Correct | 25 ms | 26708 KB | Output is correct |
8 | Correct | 82 ms | 34780 KB | Output is correct |
9 | Correct | 99 ms | 34856 KB | Output is correct |
10 | Correct | 27 ms | 26708 KB | Output is correct |
11 | Correct | 20 ms | 23728 KB | Output is correct |
12 | Correct | 32 ms | 26676 KB | Output is correct |
13 | Correct | 31 ms | 26728 KB | Output is correct |
14 | Correct | 26 ms | 26648 KB | Output is correct |
15 | Correct | 19 ms | 23816 KB | Output is correct |
16 | Correct | 26 ms | 26692 KB | Output is correct |
17 | Correct | 18 ms | 23796 KB | Output is correct |
18 | Correct | 16 ms | 23716 KB | Output is correct |
19 | Correct | 17 ms | 23928 KB | Output is correct |
20 | Correct | 31 ms | 26796 KB | Output is correct |
21 | Correct | 36 ms | 27832 KB | Output is correct |
22 | Correct | 32 ms | 27644 KB | Output is correct |
23 | Correct | 44 ms | 27424 KB | Output is correct |
24 | Correct | 36 ms | 27576 KB | Output is correct |
25 | Correct | 35 ms | 27904 KB | Output is correct |
26 | Correct | 64 ms | 33468 KB | Output is correct |
27 | Correct | 36 ms | 28856 KB | Output is correct |
28 | Correct | 26 ms | 27680 KB | Output is correct |
29 | Correct | 30 ms | 27600 KB | Output is correct |
30 | Correct | 33 ms | 27596 KB | Output is correct |
31 | Correct | 19 ms | 23792 KB | Output is correct |
32 | Correct | 19 ms | 23800 KB | Output is correct |
33 | Correct | 19 ms | 24112 KB | Output is correct |