Submission #616779

# Submission time Handle Problem Language Result Execution time Memory
616779 2022-08-01T06:43:22 Z Je_O Palinilap (COI16_palinilap) C++17
17 / 100
1000 ms 468 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s; cin >> s;
    int n = s.length();
    int ans = 0;
    for(int i = 0; i < n; ++i){
        char tmp = s[i];
        for(int j = 0; j < 26; ++j){
            s[i] = 'a' + j;
            int cnt = 0;
            for(int k = 0; k < n; ++k){
                int l = k, r = k;
                while(l >= 0 && r < n && s[l] == s[r]){
                    ++cnt;
                    --l; ++r;
                }
            }
            for(int k = 1; k < n; ++k){
                int l = k - 1, r = k;
                while(l >= 0 && r < n && s[l] == s[r]){
                    ++cnt;
                    --l; ++r;
                }
            }
            ans = max(ans, cnt);
        }
        s[i] = tmp;
    }
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 17 ms 368 KB Output is correct
3 Correct 5 ms 212 KB Output is correct
4 Correct 3 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -