Submission #249068

# Submission time Handle Problem Language Result Execution time Memory
249068 2020-07-14T09:42:27 Z kingfran1907 Palinilap (COI16_palinilap) C++14
17 / 100
1000 ms 512 KB
#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

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
1 Correct 2 ms 384 KB Output is correct
2 Correct 12 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -