# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
138623 | 2019-07-30T07:36:20 Z | KCSC | Lozinke (COCI17_lozinke) | C++14 | 1000 ms | 16760 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]++; } } 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; solve(n, ans); reverse(str + 1, str + n + 1); solve(n, ans); cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 892 KB | Output is correct |
2 | Correct | 3 ms | 1016 KB | Output is correct |
3 | Correct | 4 ms | 1016 KB | Output is correct |
4 | Correct | 5 ms | 1016 KB | Output is correct |
5 | Correct | 22 ms | 1400 KB | Output is correct |
6 | Correct | 34 ms | 1272 KB | Output is correct |
7 | Correct | 47 ms | 2040 KB | Output is correct |
8 | Correct | 76 ms | 2912 KB | Output is correct |
9 | Correct | 194 ms | 3012 KB | Output is correct |
10 | Correct | 456 ms | 7928 KB | Output is correct |
11 | Correct | 333 ms | 4472 KB | Output is correct |
12 | Correct | 972 ms | 16760 KB | Output is correct |
13 | Correct | 582 ms | 2824 KB | Output is correct |
14 | Correct | 656 ms | 14992 KB | Output is correct |
15 | Execution timed out | 1045 ms | 16504 KB | Time limit exceeded |
16 | Correct | 562 ms | 1180 KB | Output is correct |
17 | Correct | 127 ms | 888 KB | Output is correct |
18 | Correct | 95 ms | 988 KB | Output is correct |
19 | Correct | 716 ms | 8732 KB | Output is correct |
20 | Correct | 278 ms | 1272 KB | Output is correct |