Submission #165725

#TimeUsernameProblemLanguageResultExecution timeMemory
165725beso123Savez (COCI15_savez)C++14
0 / 120
1074 ms16632 KiB
#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)

savez.cpp:10:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
savez.cpp: In function 'int main()':
savez.cpp:20:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s[k].size();i++){
                 ~^~~~~~~~~~~~
#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...