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