# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22438 | PurpleNoon backward compatibility (#40) | Joyful KMP (KRIII5_JK) | C++98 | 103 ms | 221820 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<string.h>
char b[2000000];
int fa[2000000];
int bb[2000000][27],ch[100];
int main(){
int n,l,i,s,e;
unsigned long long int cnt=0,count=0;
scanf("%s",b);
l=strlen(b);
s = -1; e = 0; fa[0] = -1;
while (e < l) {
for(i=1;i<=26;i++) ch[i]=0;
cnt=0;
while (s > -1 && b[s] != b[e]) {
ch[b[s]-96]=1; s = fa[s];
}
for(i=1;i<=26;i++) {if(ch[i]==1) cnt++;}
s++; e++;
fa[e] = s;
if(fa[e]==0) {
count++;
bb[count][0]=26-cnt;
for(i=1;i<=26;i++) bb[count][i]=ch[i];
}
}
cnt=1;
for(i=1;i<=count;i++){
cnt*=bb[i][0];
cnt%=1000000007;
}
printf("%d\n",cnt);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |