# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
138624 | 2019-07-30T07:39:14 Z | KCSC | Lozinke (COCI17_lozinke) | C++14 | 507 ms | 16872 KB |
#include <bits/stdc++.h> using namespace std; const int DIM = 20005; string str[DIM]; char aux[DIM]; map<string, int> mmp; void solve(int n, int &ans) { mmp.clear(); for (int i = 1; i <= n; ++i) { ans += mmp[str[i]]; set<string> mst; for (int p1 = 0; p1 < str[i].length(); ++p1) for (int p2 = p1; p2 < str[i].length(); ++p2) mst.insert(str[i].substr(p1, p2 - p1 + 1)); for (string s : mst) mmp[s]++; } } inline bool cmp(string &s1, string &s2) { return s1.length() > s2.length(); } int main(void) { #ifdef HOME freopen("lozinke.in", "r", stdin); freopen("lozinke.out", "w", stdout); #endif int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%s", aux + 1); int m = strlen(aux + 1); for (int j = 1; j <= m; ++j) str[i].push_back(aux[j]); } int ans = 0; sort(str + 1, str + n + 1, cmp); solve(n, ans); for (int i = 1, j = 1; i <= n; i = j) { while (j <= n and str[i] == str[j]) ++j; ans += j - i - 1; } cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 888 KB | Output is correct |
2 | Incorrect | 2 ms | 1016 KB | Output isn't correct |
3 | Incorrect | 3 ms | 1016 KB | Output isn't correct |
4 | Incorrect | 4 ms | 1016 KB | Output isn't correct |
5 | Incorrect | 12 ms | 1400 KB | Output isn't correct |
6 | Incorrect | 20 ms | 1272 KB | Output isn't correct |
7 | Incorrect | 26 ms | 2040 KB | Output isn't correct |
8 | Incorrect | 40 ms | 2936 KB | Output isn't correct |
9 | Incorrect | 99 ms | 2808 KB | Output isn't correct |
10 | Incorrect | 237 ms | 7772 KB | Output isn't correct |
11 | Incorrect | 172 ms | 4344 KB | Output isn't correct |
12 | Incorrect | 470 ms | 16872 KB | Output isn't correct |
13 | Incorrect | 294 ms | 2980 KB | Output isn't correct |
14 | Incorrect | 338 ms | 14868 KB | Output isn't correct |
15 | Incorrect | 507 ms | 16400 KB | Output isn't correct |
16 | Incorrect | 279 ms | 1144 KB | Output isn't correct |
17 | Incorrect | 68 ms | 888 KB | Output isn't correct |
18 | Incorrect | 49 ms | 888 KB | Output isn't correct |
19 | Incorrect | 338 ms | 8648 KB | Output isn't correct |
20 | Incorrect | 134 ms | 1144 KB | Output isn't correct |