#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 |
1 |
Correct |
42 ms |
404 KB |
Output is correct |
2 |
Correct |
76 ms |
348 KB |
Output is correct |
3 |
Correct |
76 ms |
344 KB |
Output is correct |
4 |
Correct |
76 ms |
404 KB |
Output is correct |
5 |
Correct |
76 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1066 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1043 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |