Submission #165728

# Submission time Handle Problem Language Result Execution time Memory
165728 2019-11-28T11:56:41 Z beso123 Savez (COCI15_savez) C++14
0 / 120
1000 ms 8376 KB
#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];
        reverse(b.begin(),b.end());
       // cout<<k<<' '<<s[k]<<' '<<a<<' '<<b<<endl;
        j--;
        if(a!=b){
            break;
        }
        else{

          if(mp[a]!=0)
            dp[k]=1+dp[mp[a]];
        }
                reverse(b.begin(),b.end());
    }
    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

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 time Memory Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Incorrect 5 ms 3448 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3452 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Incorrect 11 ms 3652 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 7436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 3576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 5172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 5372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 5496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 5324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 8360 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 46 ms 8376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -