# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
613051 | 2022-07-30T03:09:10 Z | penguinhacker | HicCup (FXCUP4_hiccup) | C++17 | 63 ms | 34840 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]=='H') { adj[stk.top()].push_back(n); stk.push(n++); } else if (s[i]=='C') { stk.pop(); if (stk.empty()) return -1; } else { if (!i||s[i-1]=='H') return -1; ++cnt[stk.top()]; } } if (stk.size()!=1||n==1) return -1; dfs(); return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23764 KB | Output is correct |
2 | Correct | 16 ms | 23764 KB | Output is correct |
3 | Correct | 13 ms | 23764 KB | Output is correct |
4 | Correct | 17 ms | 24092 KB | Output is correct |
5 | Correct | 63 ms | 34820 KB | Output is correct |
6 | Correct | 18 ms | 26708 KB | Output is correct |
7 | Correct | 18 ms | 26728 KB | Output is correct |
8 | Correct | 62 ms | 34840 KB | Output is correct |
9 | Correct | 63 ms | 34828 KB | Output is correct |
10 | Correct | 20 ms | 26704 KB | Output is correct |
11 | Correct | 19 ms | 23688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23764 KB | Output is correct |
2 | Correct | 16 ms | 23764 KB | Output is correct |
3 | Correct | 13 ms | 23764 KB | Output is correct |
4 | Correct | 17 ms | 24092 KB | Output is correct |
5 | Correct | 63 ms | 34820 KB | Output is correct |
6 | Correct | 18 ms | 26708 KB | Output is correct |
7 | Correct | 18 ms | 26728 KB | Output is correct |
8 | Correct | 62 ms | 34840 KB | Output is correct |
9 | Correct | 63 ms | 34828 KB | Output is correct |
10 | Correct | 20 ms | 26704 KB | Output is correct |
11 | Correct | 19 ms | 23688 KB | Output is correct |
12 | Correct | 25 ms | 27828 KB | Output is correct |
13 | Correct | 30 ms | 27052 KB | Output is correct |
14 | Correct | 25 ms | 26732 KB | Output is correct |
15 | Correct | 14 ms | 23764 KB | Output is correct |
16 | Correct | 20 ms | 26672 KB | Output is correct |
17 | Correct | 18 ms | 23672 KB | Output is correct |
18 | Correct | 18 ms | 23744 KB | Output is correct |
19 | Correct | 19 ms | 23952 KB | Output is correct |
20 | Incorrect | 29 ms | 26776 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |