Submission #388463

#TimeUsernameProblemLanguageResultExecution timeMemory
388463phathnvVlak (COCI20_vlak)C++11
70 / 70
24 ms21800 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct Node{ int state, cnt[2]; Node *child[26]; Node(){ state = 0; cnt[0] = cnt[1] = 0; for(int i = 0; i < 26; i++) child[i] = nullptr; } }; struct Trie{ Node *root = new Node; void add(const string &s, int type){ Node *cur = root; for(char ch : s){ int nxt = ch - 'a'; if (cur->child[nxt] == nullptr) cur->child[nxt] = new Node; cur = cur->child[nxt]; cur->cnt[type]++; } } bool solve(Node *cur, int turn){ cur->state = 0; for(int i = 0; i < 26; i++){ if (cur->child[i] == nullptr) continue; if (cur->child[i]->cnt[turn] && !solve(cur->child[i], turn ^ 1)) cur->state = 1; } return cur->state; } bool solve(){ return solve(root, 0); } }; int m, n; Trie trie; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> m; for(int i = 1; i <= m; i++){ string s; cin >> s; trie.add(s, 0); } cin >> n; for(int i = 1; i <= n; i++){ string s; cin >> s; trie.add(s, 1); } cout << (trie.solve()? "Nina" : "Emilija"); 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...