# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
487517 | 2021-11-15T22:16:27 Z | Nimbostratus | Vlak (COCI20_vlak) | C++17 | 36 ms | 25956 KB |
#include "bits/stdc++.h" using namespace std; #define endl '\n' using lint = long long; using pii = pair<int,int>; constexpr int maxn = 2e5+5; constexpr int inf = 2e9; constexpr int mod = 1e9+7; struct Node { vector<int> nxt = vector<int>(26, 0); bool end[2] = {false, false}; }; vector<Node> t = vector<Node>(1); void addWord(string& s, int p, int nd = 0, int idx = 0) { if(idx == s.size()) { t[nd].end[p] = true; return; } if(!t[nd].nxt[s[idx] - 'a']) { t.push_back(Node()); t[nd].nxt[s[idx] - 'a'] = t.size() - 1; } addWord(s, p, t[nd].nxt[s[idx] - 'a'], idx + 1); for(int v : t[nd].nxt) { if(!v) continue; t[nd].end[0] |= t[v].end[0]; t[nd].end[1] |= t[v].end[1]; } } bool solve(int u = 0, int d = 0) { if(d % 2 == 0 && !t[u].end[1]) return 0; if(d % 2 == 1 && !t[u].end[0]) return 1; for(int v : t[u].nxt) { if(!v) continue; bool w = solve(v, d + 1); if(w == d % 2) return d % 2 ? 1 : 0; } return d % 2 ? 0 : 1; } int n, m; string a[maxn], b[maxn]; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for(int i = 0; i < n; i++) { cin >> a[i]; addWord(a[i], 0); } cin >> m; for(int i = 0; i < m; i++) { cin >> b[i]; addWord(b[i], 1); } cout << (solve() ? "Emilija" : "Nina") << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 13000 KB | Output is correct |
2 | Correct | 6 ms | 13024 KB | Output is correct |
3 | Correct | 5 ms | 13004 KB | Output is correct |
4 | Correct | 6 ms | 13024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13004 KB | Output is correct |
2 | Correct | 6 ms | 12972 KB | Output is correct |
3 | Correct | 6 ms | 13132 KB | Output is correct |
4 | Correct | 6 ms | 12968 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 12980 KB | Output is correct |
2 | Correct | 6 ms | 13004 KB | Output is correct |
3 | Correct | 6 ms | 12876 KB | Output is correct |
4 | Correct | 5 ms | 12980 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 12876 KB | Output is correct |
2 | Correct | 6 ms | 13004 KB | Output is correct |
3 | Correct | 6 ms | 13004 KB | Output is correct |
4 | Correct | 7 ms | 12876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 25156 KB | Output is correct |
2 | Correct | 31 ms | 24416 KB | Output is correct |
3 | Correct | 28 ms | 24640 KB | Output is correct |
4 | Correct | 31 ms | 25024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 25280 KB | Output is correct |
2 | Correct | 29 ms | 25956 KB | Output is correct |
3 | Correct | 33 ms | 24812 KB | Output is correct |
4 | Correct | 36 ms | 25016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 24616 KB | Output is correct |
2 | Correct | 32 ms | 24416 KB | Output is correct |
3 | Correct | 31 ms | 24848 KB | Output is correct |
4 | Correct | 30 ms | 25640 KB | Output is correct |