Submission #768902

#TimeUsernameProblemLanguageResultExecution timeMemory
768902DylanSmithVlak (COCI20_vlak)C++17
70 / 70
14 ms15132 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define sz(x) (int)x.size() #define all(x) begin(x),end(x) #define lb(x,y) lower_bound(all(x),y)-begin(x) mt19937 rng; typedef struct Node { int adj[26], par; bool one, two; Node(int p = -1) { one = two = 0; par = p; fill(adj, adj + 26, -1); } } node; vector<node> tree(1); int add(string &s) { int cur = 0; for (char c : s) { if (tree[cur].adj[c - 'a'] == -1) { tree[cur].adj[c - 'a'] = sz(tree); tree.emplace_back(cur); } cur = tree[cur].adj[c - 'a']; } return cur; } void solve() { int N; cin >> N; for (int i = 0; i < N; i++) { string s; cin >> s; int j = add(s); tree[j].one = true; } int M; cin >> M; for (int i = 0; i < M; i++) { string s; cin >> s; int j = add(s); tree[j].two = true; } for (int i = sz(tree) - 1; i > 0; i--) { tree[tree[i].par].one = tree[tree[i].par].one || tree[i].one; tree[tree[i].par].two = tree[tree[i].par].two || tree[i].two; } vector<int> dp1(sz(tree)), dp2(sz(tree)); fill(all(dp1), false); fill(all(dp2), false); for (int i = sz(tree) - 1; i > 0; i--) { if (!tree[i].one) dp2[i] = true; if (!tree[i].two) dp1[i] = true; if (!dp1[i]) dp2[tree[i].par] = true; if (!dp2[i]) dp1[tree[i].par] = true; } cout << (dp1[0] ? "Nina" : "Emilija") << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); rng = mt19937(chrono::steady_clock::now().time_since_epoch().count()); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...