Submission #34066

#TimeUsernameProblemLanguageResultExecution timeMemory
34066mohammad_kilaniPalindromes (APIO14_palindrome)C++14
8 / 100
1000 ms53404 KiB
#include <bits/stdc++.h> using namespace std; #define mod 10000007 #define oo 2000000000 const int N = 10040; int p = 7759; bitset < N > can[N] ; int mp[10000100]; char s[N]; bool isprime(int num){ if(num == 1) return false; for(int i=2;i*i<=num;i++) if(num % i == 0) return false; return true; } int main() { //freopen("in.txt","r",stdin); scanf("%s",s); int n = strlen(s); long long ans = 0 ; for(int i=0;i<n;i++){ int idx = i; int idx2 = i; while(idx >= 0 && idx2 < n && s[idx] == s[idx2]){ can[idx][idx2] = true; idx--; idx2++; } idx = i; idx2 = i + 1; while(idx >= 0 && idx2 < n && s[idx] == s[idx2]){ can[idx][idx2] = true; idx--; idx2++; } } for(int i=0;i<n;i++){ int tmp = 0 ; int po = 1; for(int j=i;j<n;j++){ tmp+=(((long long)(s[j]-'a'+1) * po) % mod); tmp %= mod; po = (long long)p * po % mod; int cur = ++mp[tmp]; if(can[i][j] && ans < ((long long)cur * (j-i+1))){ ans = ((long long)cur * (j-i+1)); } } } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

palindrome.cpp: In function 'int main()':
palindrome.cpp:19:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s);
               ^
#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...