제출 #134961

#제출 시각아이디문제언어결과실행 시간메모리
134961CaroLinda회문 (APIO14_palindrome)C++14
23 / 100
944 ms3484 KiB
#include <bits/stdc++.h> #define lp(i,a,b) for(int i=a;i<b;i++) #define pii pair<int,int> #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair const int inf = 0x3f3f3f3f ; const int MAXN = 1010 ; const int ALF = 30 ; const int SZTRIE = MAXN*MAXN ; using namespace std ; //Se der errado, checar o limite da trie int n ; ll ans = 0 ; string str ; bool s[MAXN][MAXN] ; map<string, ll> mapa ; void findPalindrome() { lp(i,0,n) s[i][i] = true ; lp(i,0,n-1) if( str[i] == str[i+1] ) s[i][i+1] = true ; lp(i,2,n) for(int j = 0 ; j + i < n ; j++ ) s[j][j+i] = ( s[j+1][j+i-1] && (str[j]==str[j+i]) ) ; } int main() { ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cin>>str ; n = str.size() ; findPalindrome() ; lp(i,0,n) lp(j,i,n) if(s[i][j]) { string Str ; Str.resize(j-i+1) ; for(int k = i , ind = 0 ; k <= j ; k++ , ind++ ) Str[ind] = str[k] ; if(mapa.find(Str) == mapa.end() ) mapa.insert(mk(Str,0)) ; ll tot = ++mapa[Str] ; ans = max(ans, tot*(j-i+1)) ; } cout<<ans<<endl; }
#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...