#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+50;
int n;
string a[N];
unordered_map<string, int> M;
int ans = 0;
int main(){
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i];
unordered_set<string> S;
int m = a[i].length();
for(int j=0;j<m;j++){
string s;
for(int k=j;k<m;k++){
s += a[i][k];
S.insert(s);
}
}
for(auto x : S) M[x]++;
}
for(auto x: a) ans += M[x];
cout<<ans-n;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
6656 KB |
Output is correct |
2 |
Correct |
12 ms |
6528 KB |
Output is correct |
3 |
Correct |
13 ms |
6656 KB |
Output is correct |
4 |
Correct |
12 ms |
6656 KB |
Output is correct |
5 |
Correct |
17 ms |
6912 KB |
Output is correct |
6 |
Correct |
22 ms |
6964 KB |
Output is correct |
7 |
Correct |
25 ms |
7808 KB |
Output is correct |
8 |
Correct |
33 ms |
8428 KB |
Output is correct |
9 |
Correct |
76 ms |
8312 KB |
Output is correct |
10 |
Correct |
149 ms |
13032 KB |
Output is correct |
11 |
Correct |
101 ms |
9768 KB |
Output is correct |
12 |
Correct |
347 ms |
21160 KB |
Output is correct |
13 |
Correct |
173 ms |
8384 KB |
Output is correct |
14 |
Correct |
256 ms |
19640 KB |
Output is correct |
15 |
Correct |
345 ms |
20924 KB |
Output is correct |
16 |
Correct |
170 ms |
6776 KB |
Output is correct |
17 |
Correct |
76 ms |
6528 KB |
Output is correct |
18 |
Correct |
62 ms |
6656 KB |
Output is correct |
19 |
Correct |
216 ms |
13704 KB |
Output is correct |
20 |
Correct |
95 ms |
6776 KB |
Output is correct |