(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #1110535

#TimeUsernameProblemLanguageResultExecution timeMemory
1110535simona1230Palindromes (APIO14_palindrome)C++17
0 / 100
291 ms29104 KiB
#include <bits/stdc++.h> using namespace std; const long long hey=31; const long long mod=1e9+7; map<long long,long long> mp; string s; long long ans; bool p[1024][1024]; void solve() { cin>>s; for(int i=0;i<s.size();i++) p[i][i]=1; for(int i=0;i<s.size()-1;i++) if(s[i]==s[i+1])p[i][i+1]=1; for(int l=3;l<=s.size();l++) { for(int i=0;i<s.size();i++) { int j=i+l-1; if(j>=s.size())continue; p[i][j]=p[i+1][j-1]; } } for(long long i=0;i<s.size();i++) { long long h=0; for(long long j=i;j<s.size();j++) { h=(h*hey+(long long)(s[j]-'a'+1))%mod; mp[h]++; //cout<<i<<" "<<j<<" "<<h<<" "<<(j-i+1)*mp[h]<<endl; if(p[i][j])ans=max(ans,(j-i+1)*mp[h]); } } cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); return 0; }

Compilation message (stderr)

palindrome.cpp: In function 'void solve()':
palindrome.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
palindrome.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0;i<s.size()-1;i++)
      |                 ~^~~~~~~~~~~
palindrome.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int l=3;l<=s.size();l++)
      |                 ~^~~~~~~~~~
palindrome.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int i=0;i<s.size();i++)
      |                     ~^~~~~~~~~
palindrome.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             if(j>=s.size())continue;
      |                ~^~~~~~~~~~
palindrome.cpp:29:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(long long i=0;i<s.size();i++)
      |                       ~^~~~~~~~~
palindrome.cpp:32:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(long long j=i;j<s.size();j++)
      |                           ~^~~~~~~~~
#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...