이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define wr puts("---------------")
#define all(v) v.begin(), v.end()
const int N = 3e5+5;
int weight(string s){
int ans = 0, n = (int)s.size();
for(int i = 0; i < n; ++i){
int sm = 1, l = i-1, r = i+1;
while(l >= 0 and r < n)
if(s[l] == s[r])
sm++, l--, r++;
else
break;
ans += sm;
}
for(int i = 0; i < n-1; ++i){
if(s[i] != s[i+1])
continue;
int sm = 1, l = i-1, r = i+2;
while(l >= 0 and r < n)
if(s[l] == s[r])
sm++, l--, r++;
else
break;
ans += sm;
}
return ans;
}
int main(){
string s;
cin >> s;
int n = (int)s.size(), answer = weight(s);
for(int i = 0; i < n; ++i){
char ad = s[i];
for(char c = 'a'; c <= 'z'; ++c)
s[i] = c, answer = max(answer, weight(s));
s[i] = ad;
}
printf("%d", answer);
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... |