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 <bits/stdc++.h>
using namespace std;
#define Nilou ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define int long long
#define ff first
#define ss second
const int N = 2e5 + 5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e15 ;
int n , k ;
string s ;
map <string , int> mp ;
bool a[1003][1003] ;
void solve(){
cin >> s ;
n = s.size() ; int ans = 0 ;
for ( int i = 0 ; i < n ; i ++ ){
string x , z ;
for ( int j = i ; j < n ; j ++ ){
x += s[j] ;
z = s[j]+z ;
if ( z == x ) a[i][j] = 1 ;
mp[x] ++ ;
}
}
for ( int i = 0 ; i < n ; i ++ ){
string x ;
for ( int j = i ; j < n ; j ++ ){
x += s[j] ;
if ( a[i][j] ) ans = max ( ans , mp[x]*(j-i+1) ) ;
}
}
cout << ans ;
}
signed main(){
Nilou ;
int t = 1 ;
// cin >> t ;
while ( t -- ) solve() ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |