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 <vector>
using namespace std;
int main(){
int n;
cin>>n;
vector<string>v(n+1);
v[0]="";
vector<int>dp(n+1, 0);
int ans=0;
for (int i=1; i<=n; i++){
cin>>v[i];
int siz2=v[i].size();
for (int j=0; j<i; j++){
string s=v[j];
int siz=s.size();
bool bien=true;
for (int k=0; k<siz; k++){
if (s[k]!=v[i][k] or s[k]!=v[i][siz2-siz+k]){
bien=false;
break;
}
}if (bien==true) dp[i]=max(dp[i], dp[j]+1);
}ans=max(ans, dp[i]);
}cout<<ans<<endl;
return 0;
}
# | 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... |