#include<bits/stdc++.h>
using namespace std;
int n,m;
struct trie {
trie* child[26];
int turn,type[2],val,eow;
trie() {
for (int i=0; i<26; ++i) child[i]=NULL;
turn=type[0]=type[1]=eow=0;
val=-1;
}
};
trie* root=new trie();
void add(string s, int type) {
trie* cur=root;
for (char c:s) {
if (cur->child[c-'a']==NULL) {
cur->child[c-'a']=new trie();
}
cur->child[c-'a']->turn=(cur->turn+1)%2;
cur->child[c-'a']->type[type]=1;
cur=cur->child[c-'a'];
}
cur->eow=1;
}
int calc(trie* cur) {
if (cur->val!=-1) return cur->val;
if (!cur->type[cur->turn]) return cur->val=0;
if (cur->eow) return cur->val=1;
cur->val=0;
for (int i=0; i<26; ++i) {
if (cur->child[i]==NULL) continue;
if (calc(cur->child[i])==0) cur->val=1;
}
return cur->val;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin>>n;
for (int i=1; i<=n; ++i) {
string s; cin>>s;
add(s,1);
}
cin>>m;
for (int i=1; i<=m; ++i) {
string s; cin>>s;
add(s,0);
}
root->type[0]=1;
if (calc(root)==1) cout<<"Nina"; else cout<<"Emilija";
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... |