Submission #148914

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1489142019-09-01 05:22:17Powered By Zigui (#200)HicCup (FXCUP4_hiccup)C++17
100 / 100
208 ms12180 KiB
#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;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

hiccup.cpp: In function 'int doable(std::__cxx11::string, int)':
hiccup.cpp:9:9: warning: unused variable 'cur_len' [-Wunused-variable]
     int cur_len = 0;
         ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...