Submission #205090

#TimeUsernameProblemLanguageResultExecution timeMemory
205090Haunted_CppPalinilap (COI16_palinilap)C++17
17 / 100
1093 ms504 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...