#include<bits/stdc++.h>
using namespace std;
vector<string>a;
vector<string>b;
struct node{
node* next[30];
int nhas,nwin,ehas,ewin;
node(){
for(int i=0;i<30;i++)next[i]=NULL;
nhas=nwin=ehas=ewin=0;
}
};
typedef node* pnode;
pnode rt=new node();
void dfs(pnode u){
int ewin=0;
int nwin=0;
//cerr<<u<<"\n";
for(int i=0;i<26;i++)if(u->next[i]){
//cerr<<"child:"<<u<<" "<<i<<" "<<u->next[i]<<"\n";
dfs(u->next[i]);
if((u->next[i]->nhas)&&(u->next[i]->ewin==0))nwin=1;
if((u->next[i]->ehas)&&(u->next[i]->nwin==0))ewin=1;
}
u->ewin=ewin,u->nwin=nwin;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
for(int i=0;i<n;i++){
string s;cin>>s;
pnode cur=rt;
for(auto x:s){
int id=(x-'a');
if(!cur->next[id])cur->next[id]=new node();
cur=cur->next[id];
cur->nhas=1;
}
}
int m;cin>>m;
for(int i=0;i<m;i++){
string s;cin>>s;
pnode cur=rt;
for(auto x:s){
int id=(x-'a');
if(!cur->next[id])cur->next[id]=new node();
cur=cur->next[id];
cur->ehas=1;
}
}
dfs(rt);
if(rt->nwin)cout<<"Nina\n";
else cout<<"Emilija\n";
}
# | 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... |