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;
string s;
int n;
unordered_set<string> st;
vector<string> v;
string del_first(string window){
const char* ptr = &window[1];
return ptr;
}
bool pal(string ss){
int l = 0, r = ss.size() - 1;
while(l < r){
if(ss[l] != ss[r])
return false;
l++, r--;
}
return true;
}
void seta_gos(){
for(int i = 0; i < n; ++i){
string sub = "";
for(int j = i; j < n; ++j){
sub += s[j];
st.insert(sub);
}
}
}
int occ(string ss){
int ret = 0;
int k = (int)ss.size();
string window = "";
for(int i = 0; i < k; ++i)
window += s[i];
if(window == ss)
ret++;
for(int i = k; i < n; ++i){
window += s[i];
window = del_first(window);
if(window == ss)
ret++;
}
return ret;
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> s;
n = (int)s.size();
seta_gos();
// for(string i : st)
// cout << i << "\n";
for(string i : st)
if(pal(i))
v.push_back(i);
int mx = INT_MIN;
for(string &i : v){
int den = i.size() * occ(i);
mx = max(mx, den);
}
cout << mx << "\n";
return 0;
}
# | 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... |