Submission #22438

#TimeUsernameProblemLanguageResultExecution timeMemory
22438PurpleNoon backward compatibility (#40)Joyful KMP (KRIII5_JK)C++98
2 / 7
103 ms221820 KiB
#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)

JK.cpp: In function 'int main()':
JK.cpp:28:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=1;i<=count;i++){
           ^
JK.cpp:32:19: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long unsigned int' [-Wformat=]
  printf("%d\n",cnt);
                   ^
JK.cpp:7:6: warning: unused variable 'n' [-Wunused-variable]
  int n,l,i,s,e;
      ^
JK.cpp:9:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",b);
               ^
#Verdict Execution timeMemoryGrader output
Fetching results...