답안 #73412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73412 2018-08-28T08:37:44 Z Vardanyan 회문 (APIO14_palindrome) C++14
23 / 100
1000 ms 27096 KB
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
const int N = 3000*100+7;
long long h1[N],h2[N];
long long p[N];
long long hashcode1(int l,int r){
    return h1[r]-h1[l-1]*p[r-l+1];
}
long long hashcode2(int l,int r){
    return h2[r]-h2[l-1]*p[r-l+1];
}
int main()
{
    string s;
    cin>>s;
    int n = s.length();
    p[0] = 1;
    for(int i = 1;i<=n;i++) p[i] = p[i-1]*259;
    string srev = s;
    reverse(srev.begin(),srev.end());
    for(int i = 1;i<=n;i++){
        h1[i] = h1[i-1]*259+s[i-1];
        h2[i] = h2[i-1]*259+srev[i-1];
    }
    map<long long,int> mp;
    int ans = 0;
    for(int i = 1;i<=n;i++){
        for(int j = i;j<=n;j++){
            long long x = hashcode1(i,j);
            int jj = n-i+1;
            int ii = n-j+1;
            long long y = hashcode2(ii,jj);
            if(x == y){
                    mp[x]++;
                    ans = max(ans,(j-i+1)*mp[x]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 272 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 2 ms 688 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 3 ms 688 KB Output is correct
10 Correct 3 ms 836 KB Output is correct
11 Correct 3 ms 836 KB Output is correct
12 Correct 3 ms 836 KB Output is correct
13 Correct 2 ms 836 KB Output is correct
14 Correct 3 ms 836 KB Output is correct
15 Correct 3 ms 836 KB Output is correct
16 Correct 2 ms 836 KB Output is correct
17 Correct 3 ms 836 KB Output is correct
18 Correct 3 ms 836 KB Output is correct
19 Correct 2 ms 836 KB Output is correct
20 Correct 2 ms 836 KB Output is correct
21 Correct 3 ms 836 KB Output is correct
22 Correct 4 ms 836 KB Output is correct
23 Correct 3 ms 836 KB Output is correct
24 Correct 2 ms 836 KB Output is correct
25 Correct 2 ms 836 KB Output is correct
26 Correct 2 ms 836 KB Output is correct
27 Correct 3 ms 836 KB Output is correct
28 Correct 4 ms 836 KB Output is correct
29 Correct 2 ms 836 KB Output is correct
30 Correct 4 ms 836 KB Output is correct
31 Correct 2 ms 836 KB Output is correct
32 Correct 2 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 836 KB Output is correct
2 Correct 14 ms 836 KB Output is correct
3 Correct 72 ms 836 KB Output is correct
4 Correct 7 ms 836 KB Output is correct
5 Correct 70 ms 836 KB Output is correct
6 Correct 81 ms 836 KB Output is correct
7 Correct 6 ms 836 KB Output is correct
8 Correct 39 ms 836 KB Output is correct
9 Correct 6 ms 836 KB Output is correct
10 Correct 4 ms 836 KB Output is correct
11 Correct 6 ms 836 KB Output is correct
12 Correct 5 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 1424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 9392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 27096 KB Time limit exceeded
2 Halted 0 ms 0 KB -