# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472773 | Mr_OK_Man | Lozinke (COCI17_lozinke) | C++17 | 411 ms | 16404 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 <bits/stdc++.h>
using namespace std;
int main()
{
// cout << "Hello world!" << endl;
long long n,c=0;
cin>>n;
vector<string>a(n);
map<string,long long>mp;
for(int i=0;i<n;i++)
{
cin>>a[i];
mp[a[i]]++;
}
//sort(a.begin(),a.end());
set<string>s;
for(int i=0;i<n;i++)
{
//COUNT ALL OCCURNCES IN A SET
s.clear();
for(int j=0;j<a[i].size();j++)
{
string h="";
/* h+=a[i].substr(j,a[i].size()-j);
cout<<h<<endl;
string k="";
k+=a[i].substr(0,j);
cout<<k<<endl;
s.insert(h);
s.insert(k);*/
for(int l=j;l<a[i].size();l++)
{
h+=a[i][l];
s.insert(h);
}
}
for(auto i:s)
{
c+=mp[i];
}
}
/* for(auto i:a)
{
cout<<i<<endl;
c+=mp[i]-1;
}*/
cout<<c-n<<endl;//#HABDA
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |