Submission #900047

# Submission time Handle Problem Language Result Execution time Memory
900047 2024-01-07T13:36:50 Z 1075508020060209tc Palindromes (APIO14_palindrome) C++14
23 / 100
1000 ms 131072 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
#define SZ(x) (int)(x).size()
const int mod=1e9+9;
int qpow(int x,int t){
if(t==0){return 1;}
if(t%2==1){return qpow(x,t-1)*x%mod;}
int xx=qpow(x,t/2);
return xx*xx%mod;
}
int tme[500005];
struct rlhsh{
vector<int>hsh;
int n;
void init(string s){
n=s.size();
hsh.resize(s.size()+10,0);
for(int i=1;i<=n;i++){
    hsh[i]=(hsh[i-1]+(s[i-1]-'a')*tme[i])%mod;
}
}
int gthsh(int l,int r){
int ret=(hsh[r]-hsh[l-1]+mod)*qpow(tme[l-1],mod-2)%mod;
return ret;
}
};

int n;

pair<int,int>rev(int l,int r){
l=n-l+1;r=n-r+1;
swap(l,r);
return {l,r};
}

string s;

signed main(){

tme[0]=1;
for(int i=1;i<=500000;i++){
    tme[i]=tme[i-1]*378%mod;
}

cin>>s;
map<string,int>mp;
int ans=1;
n=s.size();
s="*"+s;
for(int i=1;i<=n;i++){
    for(int j=i;j<=n;j++){
        int ok=1;
        int r=j;
        string t="";
        for(int k=i;k<=j;k++){
            if(s[k]!=s[r]){
                ok=0;
            }
            t+=s[k];
            r--;
        }
        if(ok){
            mp[t]++;
            ans=max(ans,mp[t]*(j-i+1));
        }

    }
}
cout<<ans<<"\n";



}

# Verdict Execution time Memory Grader output
1 Correct 3 ms 4184 KB Output is correct
2 Correct 4 ms 4196 KB Output is correct
3 Correct 3 ms 4188 KB Output is correct
4 Correct 3 ms 4188 KB Output is correct
5 Correct 3 ms 4188 KB Output is correct
6 Correct 3 ms 4188 KB Output is correct
7 Correct 3 ms 4188 KB Output is correct
8 Correct 3 ms 4188 KB Output is correct
9 Correct 3 ms 4188 KB Output is correct
10 Correct 3 ms 4188 KB Output is correct
11 Correct 3 ms 4184 KB Output is correct
12 Correct 3 ms 4184 KB Output is correct
13 Correct 3 ms 4188 KB Output is correct
14 Correct 4 ms 4128 KB Output is correct
15 Correct 3 ms 4188 KB Output is correct
16 Correct 3 ms 4188 KB Output is correct
17 Correct 3 ms 4188 KB Output is correct
18 Correct 3 ms 4184 KB Output is correct
19 Correct 4 ms 4356 KB Output is correct
20 Correct 4 ms 4192 KB Output is correct
21 Correct 4 ms 4184 KB Output is correct
22 Correct 4 ms 4188 KB Output is correct
23 Correct 4 ms 4188 KB Output is correct
24 Correct 4 ms 4188 KB Output is correct
25 Correct 4 ms 4188 KB Output is correct
26 Correct 4 ms 4188 KB Output is correct
27 Correct 4 ms 4184 KB Output is correct
28 Correct 4 ms 4188 KB Output is correct
29 Correct 4 ms 4188 KB Output is correct
30 Correct 4 ms 4188 KB Output is correct
31 Correct 4 ms 4188 KB Output is correct
32 Correct 4 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 445 ms 4908 KB Output is correct
2 Correct 424 ms 4648 KB Output is correct
3 Correct 488 ms 4904 KB Output is correct
4 Correct 389 ms 4380 KB Output is correct
5 Correct 477 ms 4700 KB Output is correct
6 Correct 518 ms 4904 KB Output is correct
7 Correct 389 ms 4688 KB Output is correct
8 Correct 436 ms 4948 KB Output is correct
9 Correct 443 ms 4332 KB Output is correct
10 Correct 391 ms 4336 KB Output is correct
11 Correct 378 ms 4184 KB Output is correct
12 Correct 397 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1006 ms 54080 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 671 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 675 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -