Submission #40709

#TimeUsernameProblemLanguageResultExecution timeMemory
40709HassoonySavez (COCI15_savez)C++14
72 / 120
1073 ms65536 KiB
#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; 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]; if(good1[tmp]){ tk[tmp]=max(tk[tmp],tk[s[i]]+1); } } for(auto pp:s[i]){ tmp+=pp; good1[tmp]=0; } } cout<<ans+1<<endl; }

Compilation message (stderr)

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 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...