# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
929171 | Zena_Hossam | Lozinke (COCI17_lozinke) | C++14 | 0 ms | 0 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;
#define fi ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define ll double
#define ll long long
#define F first
#define S second
#define sz size()
#define all(s) s.begin(),s.end()
#define all1(s) s.rbegin(),s.rend()
int main()
{
// freopen("maxcross.in","r",stdin);freopen("maxcross.out","w",stdout);
ll T=1;
//cin>>T;ll oo=0;
while(T--)
{
ll n;
cin>>n;
string a[n];
map<string,ll>m,d;
for(ll i=0; i<n; i++)
{
cin>>a[i];
string e="";
for(ll j=0; j<a[i].sz; j++)
{
e+=a[i][j];
d[e]=1;
}
m[a[i]]++;
}
ll c=0;
for(ll i=0; i<n; i++)
{map<string,ll>oo;
for(ll j=0; j<a[i].sz; j++)
{
string e="";
for(ll o=j;o<a[i].sz;o++){
e+=a[i][o];if(m[e]&&!oo[e]){oo[e]=1;
c+=m[e]-(e==a[i]);//cout<<i<<" "<<j<<" "<<e<<"\n";}
if(!d[e])break;
}
}
}
cout<<c;
}
}