답안 #47334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47334 2018-05-01T05:21:03 Z mirbek01 회문 (APIO14_palindrome) C++17
0 / 100
1000 ms 1952 KB
# include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 2;

string s;
int n;
long long ans, h[N], pw[N], pr = 997, mod = 1e9 + 7;
map < pair <int, int> , int> mp;

int get(int l, int r){
      long long hs = h[r] - h[l - 1];
      hs *= pw[N - l];
      return hs;
}

bool ispal(int l, int r){
      return get(l, r) == get(n - r + 1, n - l + 1);
}

int main(){
      pw[0] = pr;

      for(int i = 1; i < N; i ++)
            pw[i] = pw[i - 1] * pr;

      cin >> s;
      n = s.size();
      s = ' ' + s;

      for(int i = 1; i <= n; i ++){
            h[i] = h[i - 1] + s[i] * pw[i];
      }

      for(int i = 1; i <= n; i ++){
            for(int j = i; j <= n; j ++){
                  if(ispal(i, j)){
                        mp[{j - i + 1, get(i, j)}] ++;
                  }
            }
      }

      for(auto i : mp){
            long long cur = i.first.first * i.second;
            ans = max(ans, cur);
      }

      cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 520 KB Output is correct
3 Correct 2 ms 520 KB Output is correct
4 Correct 2 ms 616 KB Output is correct
5 Incorrect 2 ms 616 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1076 ms 1292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1412 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 1952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -