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 llint;
const int maxn = 2010;
int n;
char niz[maxn];
int main() {
scanf("%s", niz); n = strlen(niz);
int sol = 0;
for (int i = 0; i < n; i++) {
char cp = niz[i];
for (int j = 'a'; j <= 'z'; j++) {
niz[i] = j;
int tren = 0;
for (int k = 0; k < n; k++) {
int l = k, r = k;
while (true) {
//printf("tried: %d %d\n", l, r);
if (l < 0 || r >= n) break;
if (niz[l] == niz[r]) {
//printf("debug: %d %d\n", l, r);
tren++;
l--, r++;
} else break;
}
}
for (int k = 1; k < n; k++) {
int l = k - 1, r = k;
while (true) {
//printf("tried: %d %d\n", l, r);
if (l < 0 || r >= n) break;
if (niz[l] == niz[r]) {
//printf("debug: %d %d\n", l, r);
tren++;
l--, r++;
} else break;
}
}
sol = max(sol, tren);
}
niz[i] = cp;
}
printf("%d", sol);
return 0;
}
Compilation message (stderr)
palinilap.cpp: In function 'int main()':
palinilap.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", niz); n = strlen(niz);
~~~~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |