#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);
}
adj.push_back("b");
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
lozinke.cpp: In function 'int main()':
lozinke.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int k=1;k<=adj[i].length()-1;k++)
~^~~~~~~~~~~~~~~~~~~
lozinke.cpp:28:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<=(adj[i].length()-1)-k+1;j++)
~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
9728 KB |
Output isn't correct |
2 |
Incorrect |
10 ms |
9856 KB |
Output isn't correct |
3 |
Incorrect |
10 ms |
9856 KB |
Output isn't correct |
4 |
Incorrect |
11 ms |
9984 KB |
Output isn't correct |
5 |
Incorrect |
20 ms |
11256 KB |
Output isn't correct |
6 |
Incorrect |
25 ms |
11252 KB |
Output isn't correct |
7 |
Incorrect |
33 ms |
12920 KB |
Output isn't correct |
8 |
Incorrect |
33 ms |
11740 KB |
Output isn't correct |
9 |
Incorrect |
151 ms |
30116 KB |
Output isn't correct |
10 |
Incorrect |
152 ms |
17264 KB |
Output isn't correct |
11 |
Incorrect |
228 ms |
36540 KB |
Output isn't correct |
12 |
Incorrect |
375 ms |
26508 KB |
Output isn't correct |
13 |
Incorrect |
232 ms |
24796 KB |
Output isn't correct |
14 |
Incorrect |
348 ms |
44752 KB |
Output isn't correct |
15 |
Incorrect |
395 ms |
26340 KB |
Output isn't correct |
16 |
Incorrect |
157 ms |
15084 KB |
Output isn't correct |
17 |
Incorrect |
75 ms |
10872 KB |
Output isn't correct |
18 |
Incorrect |
69 ms |
14948 KB |
Output isn't correct |
19 |
Incorrect |
279 ms |
28160 KB |
Output isn't correct |
20 |
Incorrect |
214 ms |
47448 KB |
Output isn't correct |