Submission #40707

# Submission time Handle Problem Language Result Execution time Memory
40707 2018-02-06T19:54:21 Z Hassoony Savez (COCI15_savez) C++14
84 / 120
1000 ms 48252 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];
vector<string>s;
string v,tmp="";
unordered_map<string,int>tk;
unordered_map<string,bool>good1,good2;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",&oo);
        v=oo;
        s.push_back(v);
    }
    for(int i=n-1;i>=0;i--){
        ans=max(ans,tk[s[i]]);
        tmp="";
        for(auto pp:s[i]){
            tmp+=pp;
            good1[tmp]=1;
        }
        tmp="";
        for(int j=s[i].size()-1;j>=0;j--){
            tmp+=s[i][j];
            good2[tmp]=1;
        }
        for(auto pp:good1){
            if(good2[pp.first]){
                if(pp.first==s[i])continue;
                tk[pp.first]=max(tk[pp.first],tk[s[i]]+1);
            }
        }
        tk[s[i]]++;
        //cout<<endl;
        good1.clear();
        good2.clear();
    }
    cout<<ans+1<<endl;
}

Compilation message

savez.cpp: In function 'int main()':
savez.cpp:19:23: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[2000009]' [-Wformat=]
         scanf("%s",&oo);
                       ^
savez.cpp:17:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
savez.cpp:19: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 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Incorrect 2 ms 424 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 476 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 91 ms 1404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 7936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 78 ms 8096 KB Output is correct
2 Execution timed out 1074 ms 48252 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 877 ms 48252 KB Output is correct
2 Correct 851 ms 48252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 687 ms 48252 KB Output is correct
2 Correct 610 ms 48252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 504 ms 48252 KB Output is correct
2 Correct 540 ms 48252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 491 ms 48252 KB Output is correct
2 Correct 536 ms 48252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 367 ms 48252 KB Output is correct
2 Correct 344 ms 48252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 361 ms 48252 KB Output is correct
2 Correct 399 ms 48252 KB Output is correct
3 Correct 430 ms 48252 KB Output is correct