Submission #312025

#TimeUsernameProblemLanguageResultExecution timeMemory
312025FatihSolakPalinilap (COI16_palinilap)C++14
0 / 100
1094 ms20856 KiB
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; long long ans=0; int l=s.length(); long long arr[l][26]; for(int i=0;i<l;i++){ for(int j=0;j<26;j++){ arr[i][j]=0; } } for(int i=0;i<l;i++){ for(int j=i;j<l;j++){ string a=""; for(int c=i;c<=j;c++){ a +=s[c]; } string b=a; reverse(a.begin(),a.end()); if(b == a){ ans++; } else{ for(int h=0;h<(j-i+1)/2;h++){ if(b[h] != a[h]){ string d =""; for(int c=i;c<=j;c++){ if(c == i+h || c == j-h){ continue; } d+=s[c]; } string e=d; reverse(d.begin(),d.end()); if(d==e){ arr[i+h][a[h]-'a']++; arr[j-h][b[h]-'a']++; //cout << i<< " " << j << " "<< i+h <<" " << a[h] << " " << j-h << " " << b[h]<< endl; } } } } } } //cout <<endl; long long maxi=0; for(int i=0;i<l;i++){ for(int j=0;j<26;j++){ maxi = max(maxi,arr[i][j]); //cout << arr[i][j] <<" "; } //cout <<endl; } cout << maxi +ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...