# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40707 | Hassoony | Savez (COCI15_savez) | C++14 | 1082 ms | 48252 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |