Submission #635252

#TimeUsernameProblemLanguageResultExecution timeMemory
635252ojoConmigoVlak (COCI20_vlak)C++17
0 / 70
16 ms19332 KiB
#include <bits/stdc++.h> using namespace std; struct Trie{ struct Trie *child[26]; bool b[2]; //nina-0 emilija-1 }; struct Trie *createNode(){ struct Trie *nodo = new Trie; for(int i=0; i<26; i++){ nodo->child[i] = NULL; } nodo->b[0] = false; nodo->b[1] = false; return nodo; } void insert(struct Trie *root, string key, int turno){ struct Trie *curr = root; for(int i=0; i<(int)key.size(); i++){ int index = key[i] - 'a'; if(!curr->child[index]){ curr->child[index] = createNode(); } struct Trie *sig = curr->child[index]; sig->b[turno] = true; curr = curr->child[index]; } } bool gana(struct Trie *root,int turno){ struct Trie *curr = root; bool noContinua = true; for(int i=0; i<26; i++){ if(curr->child[i]){ struct Trie *sig = curr->child[i]; if(sig->b[1-turno]){ noContinua = false; if(!gana(sig,1-turno)){ return true; } } } } return noContinua; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; struct Trie *root = createNode(); for(int t=0; t<2; t++){ cin >> n; for(int i=0; i<n; i++){ string s; cin >> s; insert(root,s,t); } } bool win = false; for(int i=0; i<26; i++){ if(root->child[i]){ struct Trie *sig = root->child[i]; if(sig->b[0]){ win = max(win,gana(sig,0)); } } } if(win) cout << "Nina\n"; else cout << "Emilija\n"; }
#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...