Submission #205089

# Submission time Handle Problem Language Result Execution time Memory
205089 2020-02-27T22:32:44 Z Haunted_Cpp Palinilap (COI16_palinilap) C++17
17 / 100
1000 ms 632 KB
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define f first
#define s second
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
 
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};

int n;
string w;

int calc () {
  int tot = 0;
  for (int i = 0; i < n; i++) {
    int odd = 1;
    while (i - odd >= 0 && odd + i < n && w[i - odd] == w[i + odd]) {
      ++odd;
    }
    int even = 0;
    int l = i - 1;
    int r = i;
    while (l >= 0 && r < n && w[l] == w[r]) {
      ++even;
      --l;
      ++r;
    }
    tot += odd + even;
  }
  return tot;
}

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> w;
  n = sz(w);
  int mx = 0;
  F0R (i, n) {
    char inicial = w[i];
    F0R (j, 26) {
      w[i] = char ('a' + j);
      mx = max (mx, calc ());
    }
    w[i] = inicial;
  }
  cout << mx << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 16 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 6 ms 380 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 632 KB Time limit exceeded
2 Halted 0 ms 0 KB -