#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
6528 KB |
Output is correct |
2 |
Correct |
12 ms |
6656 KB |
Output is correct |
3 |
Correct |
12 ms |
6656 KB |
Output is correct |
4 |
Correct |
14 ms |
6656 KB |
Output is correct |
5 |
Correct |
17 ms |
6912 KB |
Output is correct |
6 |
Correct |
21 ms |
6912 KB |
Output is correct |
7 |
Correct |
43 ms |
7672 KB |
Output is correct |
8 |
Correct |
35 ms |
8440 KB |
Output is correct |
9 |
Correct |
68 ms |
8184 KB |
Output is correct |
10 |
Correct |
147 ms |
13052 KB |
Output is correct |
11 |
Correct |
105 ms |
9768 KB |
Output is correct |
12 |
Correct |
325 ms |
21176 KB |
Output is correct |
13 |
Correct |
162 ms |
8184 KB |
Output is correct |
14 |
Correct |
250 ms |
19836 KB |
Output is correct |
15 |
Correct |
344 ms |
20920 KB |
Output is correct |
16 |
Correct |
155 ms |
6776 KB |
Output is correct |
17 |
Correct |
74 ms |
6528 KB |
Output is correct |
18 |
Correct |
59 ms |
6528 KB |
Output is correct |
19 |
Correct |
196 ms |
13668 KB |
Output is correct |
20 |
Correct |
92 ms |
6656 KB |
Output is correct |