답안 #205090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
205090 2020-02-27T22:33:49 Z Haunted_Cpp Palinilap (COI16_palinilap) C++17
17 / 100
1000 ms 504 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;
    while (i - even - 1 >= 0 && i + even < n && w[i - even - 1] == w[i + even]) {
      ++even;
    }
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 16 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 504 KB Time limit exceeded
2 Halted 0 ms 0 KB -