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>
#include <unordered_map>
using namespace std;
int main(){
unordered_map<string, int>xd;
int n;
cin>>n;
vector<string>v(n+1);
v[0]="";
vector<int>dp(n+1, 1);
int ans=0;
for (int i=1; i<=n; i++){
cin>>v[i];
int siz2=v[i].size();
string s, s2;
for (int j=0; j<siz2; j++){
s+=v[i][j];
s2=v[i][siz2-1-j]+s2;
if (s!=s2) continue;
if (xd.find(s)!=xd.end()){
dp[i]=max(dp[i], dp[xd[s]]+1);
}
}xd[v[i]]=i;
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... |