#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,ssse3,sse4.1,sse4.2,avx,avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define all(x) begin(x), end(x)
#define x first
#define y second
typedef long long ll;
typedef long double ld;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using normal_queue = priority_queue<T, vector<T>, greater<T>>;
vector<string> strs;
vector<pair<string, int>> data_;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
string s;
cin >> s;
strs.push_back(s);
}
sort(all(strs));
for (int i = 0; i < n; ) {
int st = i;
while (i < n && strs[i] == strs[st])
++i;
data_.push_back({strs[st], i - st});
}
int64_t ans = 0;
for (auto g : data_) {
string s = g.x;
int sz = (int) s.size();
set<string> ss;
for (int j = 0; j < sz; ++j)
for (int h = 1; h <= sz - j; ++h)
ss.insert(s.substr(j, h));
for (string t : ss) {
auto q = lower_bound(all(data_), pair<string, int>{t, -1});
if (q != data_.end() && q->x == t)
ans += data_[q->y].y * g.y;
}
}
cout << ans - n << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
13 ms |
400 KB |
Output isn't correct |
6 |
Incorrect |
24 ms |
640 KB |
Output isn't correct |
7 |
Incorrect |
23 ms |
512 KB |
Output isn't correct |
8 |
Incorrect |
23 ms |
544 KB |
Output isn't correct |
9 |
Incorrect |
89 ms |
1396 KB |
Output isn't correct |
10 |
Incorrect |
107 ms |
1396 KB |
Output isn't correct |
11 |
Incorrect |
138 ms |
1916 KB |
Output isn't correct |
12 |
Incorrect |
199 ms |
1916 KB |
Output isn't correct |
13 |
Incorrect |
224 ms |
2296 KB |
Output isn't correct |
14 |
Incorrect |
214 ms |
3064 KB |
Output isn't correct |
15 |
Incorrect |
222 ms |
2296 KB |
Output isn't correct |
16 |
Incorrect |
34 ms |
1660 KB |
Output isn't correct |
17 |
Runtime error |
11 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
11 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Incorrect |
173 ms |
2168 KB |
Output isn't correct |
20 |
Incorrect |
37 ms |
1660 KB |
Output isn't correct |