# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
862968 | 2023-10-19T12:04:47 Z | duckindog | Vlak (COCI20_vlak) | C++14 | 22 ms | 69208 KB |
// from duckindog wth depression #include<bits/stdc++.h> using namespace std; const int N = 4 * (2e5 + 10); string a[N], b[N]; int nwt[N][27]; int st[N]; int it, bit; void add(string x, int y) { int g = 0, sz = x.size(); int cnt = 0; for (int i = bit; i >= 1; --i) { st[g] |= y; if (i <= sz) ++cnt; int ch = !cnt ? 0 : x[cnt - 1] - 'a' + 1; if (!nwt[g][ch]) nwt[g][ch] = ++it; g = nwt[g][ch]; } st[g] |= y; return; } void dfs(int g = 0) { for (int i = 0; i <= 26; ++i) { if (!nwt[g][i]) continue; char ni = !i ? '0' : char(i + 'a' - 1); cout << g << " " << nwt[g][i] << " " << ni << "\n"; dfs(nwt[g][i]); } return; } bool answer = 0; void check(int g = 0, int y = 0, int j = bit) { if (!j) { answer = 1; return; } for (int i = 0; i <= 26; ++i) { bool bel = i; int ny = y + bel; int need = ny % 2; bool trapdoor = 0; int v = nwt[g][i]; if (need && st[v] % 2 == 1) trapdoor = 1; if (!need && st[v] >= 2) trapdoor = 1; if (!v) continue; if (!i) { check(v, 0, j - 1); continue; } if (!trapdoor) continue; check(v, ny, j - 1); } return; } int32_t main() { cin.tie(0)->sync_with_stdio(0); if (fopen("duck.inp", "r")) { freopen("duck.inp", "r", stdin); freopen("duck.out", "w", stdout); } int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i], bit = max(bit, int(a[i].size())); int m; cin >> m; for (int i = 1; i <= m; ++i) cin >> b[i], bit = max(bit, int(b[i].size())); for (int i = 1; i <= n; ++i) add(a[i], 1); for (int i = 1; i <= m; ++i) add(b[i], 2); check(); cout << (answer ? "Nina" : "Emilija"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 52060 KB | Output is correct |
2 | Incorrect | 10 ms | 52060 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 52056 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 51804 KB | Output is correct |
2 | Incorrect | 10 ms | 51804 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 52056 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 67040 KB | Output is correct |
2 | Incorrect | 20 ms | 66352 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 68440 KB | Output is correct |
2 | Correct | 20 ms | 69208 KB | Output is correct |
3 | Correct | 22 ms | 68332 KB | Output is correct |
4 | Incorrect | 20 ms | 68696 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 66908 KB | Output is correct |
2 | Incorrect | 21 ms | 66652 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |