This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |