// compile: make data
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) _debug_print(#x, x);
#define Debug(x...) _debug_print_format(#x, x);
std::ifstream terminal("/dev/tty");
#define PP cerr<<"\033[1;30mpause...\e[0m",terminal.ignore();
#else
#define debug(x...)
#define Debug(x...)
#define PP
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define VI vector<int>
#define VII vector<vector<int>>
#define VIII vector<vector<vector<int>>>
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define FIND(a, x) ((find(a.begin(),a.end(),(x))!=a.end())?1:0)
#define cmin(x,...) x=min({(x), __VA_ARGS__})
#define cmax(x,...) x=max({(x), __VA_ARGS__})
#define INTMAX (int)(9223372036854775807)
#define INF (int)(1152921504606846976)
#define NaN (int)(0x8b88e1d0595d51d1)
#define double long double
#define int long long
#define uint unsigned long long
#define MAXN 200010
namespace str {
auto manacher(const string &input) {
int n = input.length();
vector<char> s(2*n + 3, '#');
vector<int> r(2*n + 3);
for (int i = 0; i < n; i++) s[2*i + 2] = input[i];
s[0] = '$', s[2*n+2] = '@';
int c = 0, maxr = 0;
rep(i, 1, 2*n+2) {
int mirror = 2*c - i;
if (i < maxr) r[i] = min(r[mirror], maxr - i);
while (s[i+r[i]+1] == s[i-r[i]-1]) ++r[i];
if (i+r[i] > maxr) c = i, maxr = i+r[i];
}
auto range = [](int C, int R) -> pair<int, int> {
return {(C-R)/2, (C+R)/2 - 1};
};
return make_pair(r, range);
}
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
string s; cin >> s;
auto [r, range] = str::manacher(s);
auto c = max_element(r.begin(), r.end()) - r.begin();
auto [L, R] = range(c, r[c]);
cout << s.substr(L, R-L+1) << endl;
return 0;
}
Having trouble logging in? I always use this plus777linklogin to quickly access my Plus777 account. Hope this helps, mga kaibigan!
Yo, jili golden empire is next level stuff. Playing it all the time! Fun and addicting! See for yourself: jili golden empire
Jili88login Philippines… for Filipinos by Filipinos? I hope they offer good promos! Tara, celebrate our hard-earned money by, uh, trying our luck. Haha! Here’s the link: jili88loginphilippines