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;
typedef long long ll;
const ll base = 727, mod = 1e9 + 9;
int main(){
string s;
cin >> s;
int n = s.size();
int ans = 0;
for (int pos = 0; pos < n; pos ++){
char p = s[pos];
for (char c = 'a'; c <= 'z'; c ++){
s[pos] = c;
int cnt = 0;
for (int l = 0; l < n; l ++){
ll hsh1 = 0;
ll hsh2 = 0;
ll pw = 1;
for (int r = l; r < n; r ++){
hsh1 = (hsh1 * base + s[r]) % mod;
hsh2 = (hsh2 + pw * s[r]) % mod;
pw = (pw * base) % mod;
if (hsh1 == hsh2)
cnt++;
}
}
ans = max(ans, cnt);
}
s[pos] = p;
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |