# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
149355 | TLEWA맞 (#200) | HicCup (FXCUP4_hiccup) | C++17 | 135 ms | 76536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include<bits/stdc++.h>
using namespace std;
vector <int> child[1010101];
int par[1010101];
priority_queue<int,vector<int>,greater<int> > pq[1001010];
int pnt;
int HicCup(std::string S) {
int H=0,C=0,A=0;
int cnt;
int N=S.size();
int c=0;
int flag=0;
for(int i=0;i<N;i++){
if(!flag&&S[i]=='H')flag=1;
if(S[i]=='H'&&i<N-1&&S[i+1]=='!'){
return -1;
}
if(S[i]=='H'){
H++;
child[c].push_back(++pnt);
par[pnt]=c;
c=pnt;
}
if(!flag&&S[i]=='C'){
return -1;
}
if(S[i]=='C'){
C++;
c=par[c];
if(C>H)return -1;
pq[c].push(0);
cnt=0;
}
if(!flag&&S[i]=='!'){
return -1;
}
if(flag&&S[i]=='!'){
int k=pq[c].top();
pq[c].pop();
pq[c].push(k+1);
cnt++;
}
}
int ret=1010101010;
if(H!=C)return -1;
for(int i=0;i<N;i++){
if(!pq[i].empty()){
ret=min(pq[i].top(),ret);
}
}
return ret;;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |