# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
148914 | Powered By Zigui (#200) | HicCup (FXCUP4_hiccup) | C++17 | 208 ms | 12180 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include <string.h>
int t[1000003];
int cur[1000003];
int len;
int doable(std::string S, int x)
{
int n = S.length();
int cur_len = 0;
memset(t, 0, sizeof(t));
memset(cur, 0, sizeof(cur));
len = 0;
int erasing = 0;
for(int i=0;i<n;i++)
{
t[len] = S[i];
cur[len] = (S[i] == '!' ? (len ? cur[len-1]+1 : 1) : 0);
len++;
if(erasing && len >= 2 && t[len-2] == 'H' && t[len-1] == '!') len--;
else if(cur[len-1] >= x && len >= x+2 && t[len-x-2] == 'H' && t[len-x-1] == 'C')
{
len -= x+2;
erasing = 1;
}
else erasing = 0;
}
for(int i=0;i<len;i++)
{
if(t[i] != '!') return 0;
}
return 1;
}
int HicCup(std::string S) {
if(S.length() && S[0] == '!') return -1;
int l = 0;
int r = S.length()+1;
if(!doable(S, 0))
{
return -1;
}
while(l<r)
{
int m = (l+r)/2;
if(doable(S, m)) l = m+1;
else r = m;
}
return l-1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |