# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104701 | Shtef | Dijamant (COI16_dijament) | C++14 | 3 ms | 384 KiB |
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 <iostream>
using namespace std;
typedef long long ll;
string s;
int n, cnt1[100005], cnt2[100005];
ll brojpalin(){
ll ret = 0;
int l = 0, r = -1;
for(int i = 0 ; i < n ; ++i){
int k = (i > r ? 1 : min(cnt1[l + r - i], r - i + 1));
while(i - k >= 0 && i + k < n && s[i - k] == s[i + k]){
k++;
}
cnt1[i] = k--;
if(i + k > r){
l = i - k;
r = i + k;
}
ret += k + 1;
int x = i - k + 1, y = i + k + 1;
}
l = 0;
r = -1;
for(int i = 0 ; i < n ; ++i){
int k = (i > r ? 0 : min(cnt1[l + r - i + 1], r - i + 1));
while(i - k - 1 >= 0 && i + k < n && s[i - k - 1] == s[i + k]){
k++;
}
cnt1[i] = k--;
if(i + k > r){
l = i - k - 1;
r = i + k;
}
ret += k + 1;
}
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
n = (int)s.size();
ll sol = brojpalin();
for(int i = 0 ; i < n ; ++i){
char poc = s[i];
for(int j = 0 ; j < 26 ; ++j){
s[i] = j + 'a';
sol = max(sol, brojpalin());
}
s[i] = poc;
}
cout << sol << endl;
return 0;
}
Compilation message (stderr)
# | 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... |