Submission #1102105

#TimeUsernameProblemLanguageResultExecution timeMemory
1102105rayan_bdVlak (COCI20_vlak)C++17
70 / 70
28 ms20560 KiB
#include <bits/stdc++.h> using namespace std; const vector<string> ans={"Emilija","Nina"}; struct Node { Node* child[26]; bool n,m; Node(){ for(int i=0;i<26;++i) child[i]=0; n=m=0; } }; Node* root = new Node(); struct Trie{ void add(string str,bool f){ Node* curr=root; for(auto it:str){ if(curr->child[it-'a']==NULL) curr->child[it-'a']=new Node(); curr=curr->child[it-'a'],curr->n|=f,curr->m|=!f; } } bool qry(Node* curr,bool f){ for(int i=0;i<26;++i){ if((curr->child[i]!=NULL&&curr->child[i]->n==f&&curr->child[i]->m==!f)||(curr->child[i]!=NULL&&curr->child[i]->n==curr->child[i]->m&&qry(curr->child[i],!f)==f)) return f; } return !f; } } tr; signed main() { int n;cin>>n; string str; for(int i=0;i<n;++i){ cin>>str; tr.add(str,1); } cin>>n; for(int i=0;i<n;++i){ cin>>str; tr.add(str,0); } cout<<ans[tr.qry(root,1)]; 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...