#include <stdio.h>
#include <string.h>
#define N 100000
#define A 26
long long max(long long a, long long b) { return a > b ? a : b; }
int main() {
static long long kk[N][A], ll[N];
static char cc[N + 1];
int n, h, i, j, i_, j_, ij, a;
long long k_;
scanf("%s", cc), n = strlen(cc);
for (ij = 0; ij <= n - 1 + n - 1; ij++)
for (i = ij / 2, j = ij - i, i_ = j_ = -1; i >= 0 && j < n; i--, j++) {
if (cc[i] != cc[j]) {
if (i_ == -1)
i_ = i, j_ = j;
else
break;
}
if (i == j)
for (h = 0; h < n; h++)
ll[h]++;
else if (i_ == -1) {
for (h = i; h <= j; h++)
kk[h][cc[h] - 'a']++;
for (h = 0; h < i; h++)
ll[h]++;
for (h = j + 1; h < n; h++)
ll[h]++;
} else
kk[i_][cc[j_] - 'a']++, kk[j_][cc[i_] - 'a']++;
}
k_ = 0;
for (i = 0; i < n; i++)
for (a = 0; a < A; a++)
k_ = max(k_, kk[i][a] + ll[i]);
printf("%lld\n", k_);
return 0;
}
Compilation message
palinilap.c: In function 'main':
palinilap.c:15:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%s", cc), n = strlen(cc);
| ^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
2672 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |