# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51904 | 2018-06-22T15:09:40 Z | EntityIT | Lozinke (COCI17_lozinke) | C++14 | 386 ms | 4076 KB |
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 20005; string s[N]; map<string, int> cnt, rem; int ans, n; signed main () { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; ++i) cin >>s[i], cnt[ s[i] ] ++; for (int i = 1; i <= n; ++i) { for (int j = 0; j < s[i].size(); ++j) { string now = ""; for (int k = j; k < s[i].size(); ++k) { now += s[i][k]; if (cnt.count(now)) { ans += cnt[now] - (j == 0 && k + 1 == s[i].size() ? 1 : 0); rem[now] += cnt[now] - (j == 0 && k + 1 == s[i].size() ? 1 : 0); cnt[now] = (j == 0 && k + 1 == s[i].size() ? 1 : 0); } } } for (auto pa : rem) cnt[ pa.first ] += pa.second; rem.clear(); } cout << ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 888 KB | Output is correct |
2 | Correct | 4 ms | 1000 KB | Output is correct |
3 | Correct | 3 ms | 1112 KB | Output is correct |
4 | Correct | 5 ms | 1224 KB | Output is correct |
5 | Correct | 17 ms | 1264 KB | Output is correct |
6 | Correct | 22 ms | 1272 KB | Output is correct |
7 | Correct | 30 ms | 1428 KB | Output is correct |
8 | Correct | 19 ms | 1428 KB | Output is correct |
9 | Correct | 238 ms | 1996 KB | Output is correct |
10 | Correct | 108 ms | 2180 KB | Output is correct |
11 | Correct | 374 ms | 2520 KB | Output is correct |
12 | Correct | 199 ms | 2772 KB | Output is correct |
13 | Correct | 386 ms | 3088 KB | Output is correct |
14 | Correct | 373 ms | 3476 KB | Output is correct |
15 | Correct | 253 ms | 3476 KB | Output is correct |
16 | Correct | 179 ms | 3476 KB | Output is correct |
17 | Correct | 26 ms | 3476 KB | Output is correct |
18 | Correct | 45 ms | 3476 KB | Output is correct |
19 | Correct | 303 ms | 4076 KB | Output is correct |
20 | Correct | 386 ms | 4076 KB | Output is correct |