# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
141091 | SeekingOblivion | Lozinke (COCI17_lozinke) | C++14 | 316 ms | 2424 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<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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |