이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
int main() {
string s;
cin >> s;
ll N=s.size();
if(N>10000) return 0;
vector<ll> A(N+1);
A[0]=0;
ll k=1;
rep(i,N) A[i+1]=(A[i]+(s[i]-'a'+1)*k)%mod,k=k*100%mod;
vector<ll> inv(N);
inv[0]=1;
rep(i,N-1) inv[i+1]=inv[i]*828542813%mod;
unordered_map<ll,ll> M1,M2;
ll ans=0;
for(ll i=0;i<N;i++){
for(ll j=0;j<min(i+1,N-i);j++){
if(s[i-j]!=s[i+j]) break;
ll x=(A[j+i+1]-A[i])*inv[i]%mod;
M1[x]+=j*2+1;
ans=max(ans,M1[x]);
}
}
for(ll i=0;i<N-1;i++){
for(ll j=0;j<min(i+1,N-1-i);j++){
if(s[i-j]!=s[i+1+j]) break;
ll x=(A[j+i+2]-A[i+1])*inv[i+1]%mod;
M2[x]+=j*2+2;
ans=max(ans,M2[x]);
}
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |