# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165725 | beso123 | Savez (COCI15_savez) | C++14 | 1074 ms | 16632 KiB |
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<bits/stdc++.h>
#define int long long
using namespace std;
string s[100005];
int n,dp[100005];
map<string,int> mp;
bool sort12(string a,string b){
return a.size()<b.size();
}
main(){
cin>>n;
for(int k=1;k<=n;k++){
cin>>s[k];
dp[k]=1;
}
sort(s+1,s+n+1,sort12);
for(int k=1;k<=n;k++){
string a,b;
int j=s[k].size()-1;
for(int i=0;i<s[k].size();i++){
a+=s[k][i];
b+=s[k][j];
j--;
if(a!=b){
break;
}
else{
//cout<<k<<' '<<s[k]<<' '<<a<<endl;
if(mp[a]!=0)
dp[k]=1+dp[mp[a]];
}
}
mp[s[k]]=k;
}
int ans=0;
for(int k=1;k<=n;k++)
ans=max(ans,dp[k]);
cout<<ans;
return 0;
}
Compilation message (stderr)
# | 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... |