#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
string str;cin>>str;
//O(n^2) ハッシュ
map<pair<llint,int>,int>ha;
int i,j,s,t,n=str.size();
if(n>10000){return 0;}
for(i=0;i<n;i++){
s=i,t=i;
int naga=-1;
llint roll=0;
while(s>=0&&t<n&&str[s]==str[t]){
naga+=2;
roll*=1001;roll+=str[s];roll%=mod;ha[mp(roll,naga)]++;
s--;t++;
}
naga=0;s=i;t=i+1;roll=0;
while(s>=0&&t<n&&str[s]==str[t]){
naga+=2;
roll*=1001;roll+=str[s];roll%=mod;ha[mp(roll,naga)]++;
s--;t++;
}
}
llint ans=0;
for(auto it:ha){maxeq(ans,it.fir.sec*it.sec);}
cout<<ans<<endl;
return 0;
}
Compilation message
palindrome.cpp: In function 'int main()':
palindrome.cpp:52:8: warning: unused variable 'j' [-Wunused-variable]
int i,j,s,t,n=str.size();
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
2 ms |
560 KB |
Output is correct |
7 |
Correct |
2 ms |
560 KB |
Output is correct |
8 |
Correct |
2 ms |
588 KB |
Output is correct |
9 |
Correct |
2 ms |
588 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
2 ms |
588 KB |
Output is correct |
12 |
Correct |
2 ms |
588 KB |
Output is correct |
13 |
Correct |
2 ms |
588 KB |
Output is correct |
14 |
Correct |
2 ms |
588 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
2 ms |
588 KB |
Output is correct |
17 |
Correct |
2 ms |
588 KB |
Output is correct |
18 |
Correct |
2 ms |
588 KB |
Output is correct |
19 |
Correct |
2 ms |
588 KB |
Output is correct |
20 |
Correct |
2 ms |
588 KB |
Output is correct |
21 |
Correct |
2 ms |
588 KB |
Output is correct |
22 |
Correct |
2 ms |
644 KB |
Output is correct |
23 |
Correct |
2 ms |
648 KB |
Output is correct |
24 |
Correct |
2 ms |
648 KB |
Output is correct |
25 |
Correct |
2 ms |
708 KB |
Output is correct |
26 |
Correct |
2 ms |
708 KB |
Output is correct |
27 |
Correct |
2 ms |
716 KB |
Output is correct |
28 |
Correct |
2 ms |
720 KB |
Output is correct |
29 |
Correct |
2 ms |
720 KB |
Output is correct |
30 |
Correct |
2 ms |
720 KB |
Output is correct |
31 |
Correct |
2 ms |
720 KB |
Output is correct |
32 |
Correct |
2 ms |
736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
748 KB |
Output is correct |
2 |
Correct |
10 ms |
752 KB |
Output is correct |
3 |
Correct |
33 ms |
756 KB |
Output is correct |
4 |
Correct |
3 ms |
760 KB |
Output is correct |
5 |
Correct |
43 ms |
892 KB |
Output is correct |
6 |
Correct |
39 ms |
896 KB |
Output is correct |
7 |
Correct |
3 ms |
896 KB |
Output is correct |
8 |
Correct |
17 ms |
896 KB |
Output is correct |
9 |
Correct |
2 ms |
896 KB |
Output is correct |
10 |
Correct |
2 ms |
896 KB |
Output is correct |
11 |
Correct |
2 ms |
896 KB |
Output is correct |
12 |
Correct |
3 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1086 ms |
1316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
1700 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |