Submission #959193

#TimeUsernameProblemLanguageResultExecution timeMemory
959193lalig777Savez (COCI15_savez)C++14
120 / 120
344 ms37432 KiB
#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 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...