#include<bits/stdc++.h>
#define int long long
using namespace std;
int res=0,n,fact[300005];
string t;
vector<string> adj,ditme;
map<string,int> cnt;
map<string,bool> cur[300005];
bool cmp (string a,string b)
{
return a.length()<b.length();
}
signed main()
{
cin>>n;
fact[0]=1;
for(int i=1;i<=200005;i++)
fact[i]=fact[i-1]*i;
for(int i=1;i<=n;i++)
{
cin>>t;
adj.push_back(t);
}
sort(adj.begin(),adj.end(),cmp);
adj.push_back("b");
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())
{
// cout<<"VAILON";
res+=fact[cnt[adj[i]]]/fact[cnt[adj[i]]-2];
}
}
cout<<res;
}
Compilation message
lozinke.cpp: In function 'int main()':
lozinke.cpp:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int k=1;k<=adj[i].length()-1;k++)
~^~~~~~~~~~~~~~~~~~~
lozinke.cpp:31:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<=(adj[i].length()-1)-k+1;j++)
~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
16128 KB |
Output isn't correct |
2 |
Incorrect |
15 ms |
16000 KB |
Output isn't correct |
3 |
Incorrect |
17 ms |
16128 KB |
Output isn't correct |
4 |
Incorrect |
17 ms |
16256 KB |
Output isn't correct |
5 |
Incorrect |
26 ms |
17528 KB |
Output isn't correct |
6 |
Incorrect |
30 ms |
17524 KB |
Output isn't correct |
7 |
Incorrect |
42 ms |
19184 KB |
Output isn't correct |
8 |
Incorrect |
42 ms |
17948 KB |
Output isn't correct |
9 |
Runtime error |
37 ms |
32744 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
10 |
Incorrect |
158 ms |
23088 KB |
Output isn't correct |
11 |
Runtime error |
43 ms |
33008 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
12 |
Incorrect |
382 ms |
32104 KB |
Output isn't correct |
13 |
Incorrect |
224 ms |
29020 KB |
Output isn't correct |
14 |
Runtime error |
47 ms |
33388 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
15 |
Incorrect |
383 ms |
32076 KB |
Output isn't correct |
16 |
Incorrect |
157 ms |
19256 KB |
Output isn't correct |
17 |
Runtime error |
98 ms |
33516 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
18 |
Runtime error |
52 ms |
33388 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
19 |
Incorrect |
293 ms |
33268 KB |
Output isn't correct |
20 |
Runtime error |
48 ms |
33388 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |