Submission #439464

#TimeUsernameProblemLanguageResultExecution timeMemory
439464ldn694Vlak (COCI20_vlak)C++17
70 / 70
22 ms20164 KiB
#include <bits/stdc++.h> #define fu(i, a, b) for (int i = a; i <= b; i++) #define fd(i, a, b) for (int i = a; i >= b; i--) using namespace std; const int N = 2e5 + 10; int num[2]; struct Node { Node *child[26]; bool ticket[2]; Node() { fu(i, 0, 25) child[i] = NULL; fu(i, 0, 1) ticket[i] = false; } }; Node *root; void Insert(const string &a, int o) { Node *pos = root; for (char x : a) { int v = int(x) - 97; if (pos->child[v] == NULL) pos->child[v] = new Node(); pos->child[v]->ticket[o] = true; pos = pos->child[v]; } } bool win(Node *u, int o) { bool passed = false; fu(i, 0, 25) { if (u->child[i] == NULL) continue; if (!u->child[i]->ticket[o]) continue; passed |= !win(u->child[i], 1 - o); if (passed) break; } return passed; } int main() { cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false); root = new Node(); fu(i, 0, 1) { cin >> num[i]; fu(j, 1, num[i]) { string s; cin >> s; Insert(s, i); } } cout << (win(root, 0) ? "Nina" : "Emilija"); }
#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...