#include<bits/stdc++.h>
using namespace std;
int n;
string l[20014];
unordered_set<string> s;
unordered_map<string, int> cnt;
int main(void) {
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> l[i];
s.clear();
for (int j = 0; j < (int) l[i].size(); ++j) {
string a;
for (int k = j; k < (int) l[i].size(); ++k) {
a.push_back(l[i][k]);
s.insert(a);
}
}
for (auto &x : s)
cnt[x]++;
}
int sol = 0;
for (auto &x : l)
sol += cnt[x];
cout << sol - n << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1024 KB |
Output is correct |
2 |
Correct |
3 ms |
896 KB |
Output is correct |
3 |
Correct |
4 ms |
1024 KB |
Output is correct |
4 |
Correct |
4 ms |
1024 KB |
Output is correct |
5 |
Correct |
7 ms |
1280 KB |
Output is correct |
6 |
Correct |
10 ms |
1280 KB |
Output is correct |
7 |
Correct |
13 ms |
2048 KB |
Output is correct |
8 |
Correct |
19 ms |
2688 KB |
Output is correct |
9 |
Correct |
43 ms |
2552 KB |
Output is correct |
10 |
Correct |
112 ms |
7272 KB |
Output is correct |
11 |
Correct |
74 ms |
4136 KB |
Output is correct |
12 |
Correct |
260 ms |
15288 KB |
Output is correct |
13 |
Correct |
113 ms |
2552 KB |
Output is correct |
14 |
Correct |
190 ms |
13912 KB |
Output is correct |
15 |
Correct |
270 ms |
14960 KB |
Output is correct |
16 |
Correct |
110 ms |
1144 KB |
Output is correct |
17 |
Correct |
59 ms |
1024 KB |
Output is correct |
18 |
Correct |
43 ms |
896 KB |
Output is correct |
19 |
Correct |
151 ms |
7832 KB |
Output is correct |
20 |
Correct |
59 ms |
1152 KB |
Output is correct |