Submission #141091

#TimeUsernameProblemLanguageResultExecution timeMemory
141091SeekingOblivionLozinke (COCI17_lozinke)C++14
100 / 100
316 ms2424 KiB
#include<iostream> #include<fstream> #include<cstring> #include<algorithm> #include<map> #include<set> #define fin cin #define fout cout #include<vector> using namespace std; //ifstream fin("date.in"); //ofstream fout("date.out"); map<string,int> m; set<string> s; set<string>::iterator it; int n,i,j,h,p,sol; pair<int,int> v[20010]; string c[20010]; int main(){ fin>>n; for(i=1;i<=n;i++) { fin>>c[i]; v[i].first=c[i].size(); v[i].second=i; } sort(v+1, v+n+1); for(i=1;i<=n;i++) { s.clear(); p=v[i].second; for(j=0;c[p][j];j++) for(h=j;c[p][h];h++) s.insert(c[p].substr(j,h-j+1)); for(it=s.begin();it!=s.end();it++) { if(m.find(*it)!=m.end()) { sol+=m[*it]; if(*it==c[p]) sol+=m[*it]; } } if(m.find(c[p])==m.end()) m[c[p]]=1; else m[c[p]]++; } fout<<sol; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...