This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <bits/stdc++.h>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
unordered_map<ll,int>hmap;
int n,length;
ll l,r,base,val;
string input;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for(int i=0;i<n;i++){
cin>>input;
length=input.length();
l=0;
r=0;
base=1;
val=0;
for(int i=0;i<length;i++){
l=(27*l+input[i]-'A'+1)%mod;
r=(r+base*(input[length-i-1]-'A'+1))%mod;
base=(27*base)%mod;
if(l==r&&hmap.find(l)!=hmap.end()&&hmap[l]>val)val=hmap[l];
}
val++;
hmap[l]=val;
}
int output=0;
for(auto&i:hmap)output=max(output,i.second);
cout<<output;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |