# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
148943 | 2019-09-01T05:26:00 Z | 본인 방금 올솔하는 상상함(#3610, gs18113, dennisstar, red1108) | HicCup (FXCUP4_hiccup) | C++17 | 6 ms | 384 KB |
#include "hiccup.h" #include<bits/stdc++.h> #define N 1000005 using namespace std; typedef pair<int,int> pi; int cnt[N]; int ch[N]; int nxt[N]; int asdf[N]; int HicCup(std::string S) { int n = S.size(); stack<pi> st; stack<pi> st2; int lv=0; int last=0; for(int i=0;i<n;i++){ if(S[i]=='H'){ lv++; st.push(pi(i, lv)); st2.push(pi(i, lv)); } else if(S[i]=='C'){ pi t=st.top(); st.pop(); while(!st2.empty()&&(st2.top().second>lv||st2.top()==t)){ st2.pop(); } if(!st2.empty()) { nxt[st2.top().first]=t.first+1; } st2.push(t); lv--; } else{ if(lv==st2.top().second) return -1; cnt[st2.top().first]++; } } int sum=0; int c=0; int ans=INT_MAX; for(int i=0;i<n;i++){ if(ch[i]) continue; if(S[i]!='H') continue; else{ sum=0; c=0; for(int j=i+1;j;j=nxt[j-1]){ ch[j-1]=1; sum+=cnt[j-1]; c++; } ans=min(ans, sum/c); } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Runtime error | 5 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Runtime error | 5 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |