# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
867386 | 2023-10-28T10:02:14 Z | Vladth11 | Lozinke (COCI17_lozinke) | C++14 | 61 ms | 65536 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 = 200002; 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]; short 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 | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 860 KB | Output is correct |
6 | Correct | 1 ms | 860 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 | 8 ms | 10072 KB | Output is correct |
11 | Correct | 5 ms | 5212 KB | Output is correct |
12 | Runtime error | 61 ms | 65536 KB | Execution killed with signal 9 |
13 | Correct | 7 ms | 2908 KB | Output is correct |
14 | Correct | 13 ms | 20160 KB | Output is correct |
15 | Correct | 17 ms | 22364 KB | Output is correct |
16 | Correct | 8 ms | 604 KB | Output is correct |
17 | Correct | 5 ms | 604 KB | Output is correct |
18 | Correct | 4 ms | 348 KB | Output is correct |
19 | Correct | 10 ms | 11100 KB | Output is correct |
20 | Correct | 4 ms | 600 KB | Output is correct |