Submission #135024

#TimeUsernameProblemLanguageResultExecution timeMemory
135024Kenzo_1114Palindromes (APIO14_palindrome)C++14
8 / 100
1088 ms81524 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN=10010; const long long int MOD=100000010; long long int resp[MOD],tam[MOD],fe[MAXN]; string word; char aux[MAXN]; long long int RESP; void valid(int i,int j) { int mid=(j-i)/2, ok=1, cont=1; long long int novo=1; for(int k=0;k<=mid;k++) if(word[i+k]!=word[j-k]) ok=0; if(ok) for(int k=i;k<=j;k++) { long long int aux=(int)word[k]; novo+=(aux*fe[cont])%MOD; cont++; if(novo>=MOD) novo%=MOD; } // printf("i = %d j = %d ok = %d novo = %lld\n",i,j,ok,novo); if(ok) resp[novo]++, tam[novo]=cont-1; } void init() { for(int i=0;i<MAXN;i++) fe[i]=rand()%MOD; // for(int i=0;i<=7;i++) printf("fe[%d] = %lld\n",i,fe[i]); } int main () { srand(time(0)); init(); scanf(" %s",aux); word=(string)aux; for(int i=0;i<word.size();i++) { for(int j=i;j<word.size();j++) { valid(i,j); } } for(int i=0;i<MOD;i++) RESP=max(RESP,tam[i]*resp[i]); printf("%lld\n",RESP); }

Compilation message (stderr)

palindrome.cpp: In function 'int main()':
palindrome.cpp:48:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<word.size();i++)
              ~^~~~~~~~~~~~
palindrome.cpp:50:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=i;j<word.size();j++)
               ~^~~~~~~~~~~~
palindrome.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %s",aux);
  ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...