제출 #41653

#제출 시각아이디문제언어결과실행 시간메모리
41653funcsr회문 (APIO14_palindrome)C++14
47 / 100
644 ms29952 KiB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cassert>
#include <map>
using namespace std;
#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define index(x, y) (int)(lower_bound(all(x), y) - x.begin())
#define _1 first
#define _2 second
#define pb push_back
#define MOD 1000000007
const int B = 321;

string S;
int N;
map<int, int> C[300001];
signed main() {
  cin >> S;
  N = S.length();
  assert(N <= 10000);
  rep(l, N) {
    int h = 0, rev = 0, p = 1;
    for (int r=l; r<N; r++) {
      h = (h*B+S[r])%MOD;
      rev = (rev+1LL*p*S[r]) % MOD;
      if (h == rev) C[r-l+1][h]++;
      p = (1LL*p*B) % MOD;
    }
  }
  long long m = 0;
  for (int len=1; len<=N; len++) {
    for (auto p : C[len]) {
      m = max(m, 1LL*len*p._2);
    }
  }
  cout << m << "\n";
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...