# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472774 | SaraMostafa | Lozinke (COCI17_lozinke) | C++14 | 273 ms | 16400 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>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define Sara ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=998244353;
const double PI=acos(-1);
int main()
{
//freopen("input.in","r",stdin);
Sara
int n;
cin>>n;
vector<string>v(n);
map<string,ll>mp;
for(int i=0; i<n; i++)
{
cin>>v[i];
mp[v[i]]++;
}
ll cnt=0;
for(int i=0; i<n; i++)
{
map<string,bool>vs;
for(int k=0; k<v[i].size(); k++)
{
string c="";
for(int j=k; j<v[i].size(); j++)
{
c+=v[i][j];
if(mp[c]==0 || vs[c]) continue;
else if(c==v[i])
cnt+=(mp[c]-1);
else cnt+=mp[c];
vs[c]=1;
}
}
}
cout<<cnt<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |