# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
917960 | 2024-01-29T07:58:16 Z | 406 | Lozinke (COCI17_lozinke) | C++17 | 254 ms | 35904 KB |
#include <bits/stdc++.h> #define int int64_t #define FOR(i, a, b) for (int i = (a); i < (b); ++i) using namespace std; using ar = array<int, 2>; const int64_t INF = 1ll << 60; const int N = 2e4 + 5; string s[N]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<string> V; FOR(i, 0, n) { cin >> s[i]; vector<string> v; FOR(k, 0, s[i].size()) { string a; FOR(j, k, s[i].size()) { a += s[i][j]; v.push_back(a); } } sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end()) - v.begin()); V.insert(V.end(), v.begin(), v.end()); } sort(V.begin(), V.end()); int ans = -n; FOR(i, 0, n) { int L = lower_bound(V.begin(), V.end(), s[i]) - V.begin(); int R = upper_bound(V.begin(), V.end(), s[i]) - V.begin(); ans += R - L; } cout << ans << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 860 KB | Output is correct |
3 | Correct | 1 ms | 1116 KB | Output is correct |
4 | Correct | 2 ms | 1340 KB | Output is correct |
5 | Correct | 8 ms | 2220 KB | Output is correct |
6 | Correct | 15 ms | 2368 KB | Output is correct |
7 | Correct | 14 ms | 2764 KB | Output is correct |
8 | Correct | 22 ms | 3904 KB | Output is correct |
9 | Correct | 64 ms | 12116 KB | Output is correct |
10 | Correct | 112 ms | 13868 KB | Output is correct |
11 | Correct | 96 ms | 14036 KB | Output is correct |
12 | Correct | 213 ms | 24652 KB | Output is correct |
13 | Correct | 211 ms | 30428 KB | Output is correct |
14 | Correct | 153 ms | 21464 KB | Output is correct |
15 | Correct | 235 ms | 31784 KB | Output is correct |
16 | Correct | 254 ms | 35904 KB | Output is correct |
17 | Correct | 101 ms | 12628 KB | Output is correct |
18 | Correct | 77 ms | 10852 KB | Output is correct |
19 | Correct | 179 ms | 31188 KB | Output is correct |
20 | Correct | 127 ms | 16740 KB | Output is correct |