Submission #453793

#TimeUsernameProblemLanguageResultExecution timeMemory
453793RGBBSavez (COCI15_savez)C++14
120 / 120
110 ms2248 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...