#include <bits/stdc++.h>
using namespace std;
int n;
map <string, int> podniz;
vector <string> s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
s.resize(n);
for (int i = 0; i < n; i++) {
cin >> s[i];
}
for (auto x : s) {
set <string> ss;
for (unsigned i = 0; i < x.size(); i++) {
for (unsigned j = i; j < x.size(); j++) {
ss.insert(x.substr(i, x.size() - j));
}
}
for (auto xx : ss) {
podniz[xx]++;
}
}
/*
for (auto x : podniz) {
cout << x.first << " " << x.second << '\n';
}
*/
int koliko = 0;
for (auto x : s) {
koliko += podniz[x];
}
cout << koliko - n;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
360 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
16 ms |
744 KB |
Output is correct |
6 |
Correct |
27 ms |
744 KB |
Output is correct |
7 |
Correct |
29 ms |
1528 KB |
Output is correct |
8 |
Correct |
41 ms |
2272 KB |
Output is correct |
9 |
Correct |
117 ms |
2504 KB |
Output is correct |
10 |
Correct |
268 ms |
7672 KB |
Output is correct |
11 |
Correct |
172 ms |
4344 KB |
Output is correct |
12 |
Correct |
470 ms |
16632 KB |
Output is correct |
13 |
Correct |
303 ms |
2936 KB |
Output is correct |
14 |
Correct |
415 ms |
15096 KB |
Output is correct |
15 |
Correct |
497 ms |
16504 KB |
Output is correct |
16 |
Correct |
323 ms |
1280 KB |
Output is correct |
17 |
Correct |
89 ms |
1152 KB |
Output is correct |
18 |
Correct |
71 ms |
1152 KB |
Output is correct |
19 |
Correct |
359 ms |
8836 KB |
Output is correct |
20 |
Correct |
163 ms |
1272 KB |
Output is correct |