# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
867380 | 2023-10-28T09:59:32 Z | Vladth11 | Lozinke (COCI17_lozinke) | C++14 | 19 ms | 23900 KB |
#include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " #pragma GCC optimize("Ofast") using namespace std; typedef long long ll; typedef pair <int, int> pii; const ll NMAX = 100002; const ll INF = (1LL << 60); const ll nrbits = 20; const ll MOD = 998244353; const ll bucket = 320; const double eps = 0.00000001; int trie[NMAX][26]; int last[NMAX]; int nr[NMAX]; int subsecv[NMAX]; int cnt = 0; int root; ll sol; string s; int acum; void baga(int node, int idx, int full) { if(last[node] != acum) { sol += nr[node]; subsecv[node]++; } last[node] = acum; if(idx == s.size()) { nr[node] += full; if(full){ sol += (subsecv[node] - 1); } return; } if(node == root) { for(int i = 0; i < s.size(); i++) { int nxt = s[i] - 'a'; if(trie[node][nxt] == 0) { trie[node][nxt] = ++cnt; } baga(trie[node][nxt], i + 1, (i == 0)); } return; } int nxt = s[idx] - 'a'; if(trie[node][nxt] == 0) { trie[node][nxt] = ++cnt; } baga(trie[node][nxt], idx + 1, full); } signed main() { #ifdef HOME ifstream cin(".in"); ofstream cout(".out"); #endif // HOME ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, i; root = ++cnt; cin >> n; for(i = 1; i <= n; i++) { cin >> s; acum = i; baga(root, 0, 1); } cout << sol; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 464 KB | Output is correct |
3 | Correct | 0 ms | 464 KB | Output is correct |
4 | Correct | 0 ms | 464 KB | Output is correct |
5 | Correct | 1 ms | 860 KB | Output is correct |
6 | Correct | 1 ms | 984 KB | Output is correct |
7 | Correct | 1 ms | 1884 KB | Output is correct |
8 | Correct | 2 ms | 3164 KB | Output is correct |
9 | Correct | 3 ms | 2908 KB | Output is correct |
10 | Correct | 7 ms | 10332 KB | Output is correct |
11 | Correct | 5 ms | 5468 KB | Output is correct |
12 | Runtime error | 17 ms | 23900 KB | Execution killed with signal 11 |
13 | Correct | 7 ms | 3164 KB | Output is correct |
14 | Runtime error | 15 ms | 23640 KB | Execution killed with signal 11 |
15 | Runtime error | 19 ms | 23644 KB | Execution killed with signal 11 |
16 | Correct | 6 ms | 860 KB | Output is correct |
17 | Correct | 5 ms | 472 KB | Output is correct |
18 | Correct | 4 ms | 604 KB | Output is correct |
19 | Correct | 10 ms | 11612 KB | Output is correct |
20 | Correct | 4 ms | 604 KB | Output is correct |