# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116866 | TienDungz | Lozinke (COCI17_lozinke) | C++14 | 357 ms | 44632 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>
#define int long long
using namespace std;
int res=0,n;
string t;
vector<string> adj,ditme;
map<string,int> cnt;
map<string,bool> cur[200005];
bool cmp (string a,string b)
{
return a.length()<b.length();
}
signed main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>t;
adj.push_back(t);
}
sort(adj.begin(),adj.end(),cmp);
for(int i=0;i<n;i++)
{
for(int k=1;k<=adj[i].length()-1;k++)
{
string s[20];
for(int j=0;j<=(adj[i].length()-1)-k+1;j++)
{
s[j]=adj[i].substr(j,k);
if(cnt[s[j]]>=1&&cur[i][s[j]]==false)
{
res+=cnt[s[j]];
cur[i][s[j]]=true;
ditme.push_back(s[j]);
}
}
}
cnt[adj[i]]++;
if(cnt[adj[i]]>=2&&(adj[i+1].length()>adj[i].length()||i==n-1))
{
int temp=1;
for(int j=1;j<=cnt[adj[i]];j++)
{
temp=temp*j;
}
res+=temp;
}
}
cout<<res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |