Submission #1024535

# Submission time Handle Problem Language Result Execution time Memory
1024535 2024-07-16T07:05:20 Z KasymK Palinilap (COI16_palinilap) C++17
17 / 100
1000 ms 600 KB
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define wr puts("---------------")
#define all(v) v.begin(), v.end()
const int N = 3e5+5;

int weight(string s){
    int ans = 0, n = (int)s.size();
    for(int i = 0; i < n; ++i){
        int cnt = 1, l = i-1, r = i+1;
        while(l >= 0 and r < n){
            if(s[l] == s[r])
                cnt++, l--, r++;
            else
                break;
	    }
        ans += cnt;
    }
    for(int i = 0; i < n-1; ++i){
        if(s[i] != s[i+1])
            continue;
        int cnt = 1, l = i-1, r = i+2;
        while(l >= 0 and r < n){
            if(s[l] == s[r])
                cnt++, l--, r++;
            else
                break;
        }
        ans += cnt;
    }
    return ans;
}

int main(){
    string s;
    cin >> s;
    int n = (int)s.size(), answer = weight(s);
    for(int i = 0; i < n; ++i){
        char ad = s[i];
        for(char c = 'a'; c <= 'z'; ++c)
            s[i] = c, answer = max(answer, weight(s));
        s[i] = ad;
    }
    printf("%d", answer);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 9 ms 424 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 440 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1025 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -