# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
149007 | 본인 방금 올솔하는 상상함 (#200) | HicCup (FXCUP4_hiccup) | C++17 | 49 ms | 14848 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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'){
if(st.empty()) return -1;
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(st2.empty()||lv==st2.top().second) return -1;
cnt[st2.top().first]++;
}
}
if(!st.empty()) return -1;
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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |