Submission #40705

# Submission time Handle Problem Language Result Execution time Memory
40705 2018-02-06T19:48:34 Z Hassoony Savez (COCI15_savez) C++14
0 / 120
1 ms 516 KB
#include <stdio.h>
#include <stdlib.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
const ll inf=(1ll<<61);
const ll mod=1e9+7;
const int MX=2e6+9;
int n,ans;
char oo[MX];
string s[MX];
unordered_map<string,int>tk;
unordered_map<string,int>good1,good2;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",&oo);
        s[i]=oo;
    }
    for(int i=n-1;i>=0;i--){
     //   cout<<i<<" "<<s[i]<<endl;
        ans=max(ans,tk[s[i]]);
        string tmp="";
        for(auto pp:s[i]){
            tmp+=pp;
            good1[tmp]=1;
        }
        tmp="";
        reverse(s[i].begin(),s[i].end());
        for(auto pp:s[i]){
            tmp+=pp;
            good2[tmp]=1;
        }
        reverse(s[i].begin(),s[i].end());
        for(auto pp:good1){
            if(good2[pp.first]){
                    if(pp.first==s[i]&&s[i].size()!=1)continue;
      //          cout<<pp.first<<" ";
                tk[pp.first]=max(tk[pp.first],tk[s[i]]+1);
            }
        }
        //cout<<endl;
        good1.clear();
        good2.clear();
    }
    cout<<ans+1<<endl;
}

Compilation message

savez.cpp: In function 'int main()':
savez.cpp:18:23: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[2000009]' [-Wformat=]
         scanf("%s",&oo);
                       ^
savez.cpp:16:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
savez.cpp:18:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",&oo);
                        ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 128 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 1 ms 224 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 1 ms 312 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 1 ms 340 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 1 ms 496 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 1 ms 496 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 1 ms 496 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 1 ms 516 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 1 ms 516 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 1 ms 516 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -