#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef pair<int,pii>pi2;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
int nxt[200005][30];
bool val[200005][2];
int ptr=2;
int dp(int index, bool amos){
if(amos){
bool ans=false;
for(int x=0;x<30;x++){
int target=nxt[index][x];
if(target==0) continue;
if(val[target][0]&&!val[target][1]) return true;
if(val[target][0]) ans|=dp(target,!amos);
}
return ans;
}
else{
bool ans=true;
for(int x=0;x<30;x++){
int target=nxt[index][x];
if(target==0) continue;
if(val[target][1]&&!val[target][0]) return false;
if(val[target][1]) ans&=dp(target,!amos);
}
return ans;
}
}
void solve(){
int n;
cin >> n;
string s;
for(int x=0;x<n;x++){
cin >> s;
int cur=1;
for(auto it:s){
int hold=it-'a';
if(nxt[cur][hold]==0){
nxt[cur][hold]=ptr++;
}
cur=nxt[cur][hold];
val[cur][0]=true;
}
}
int m;
cin >> m;
for(int x=0;x<m;x++){
cin >> s;
int cur=1;
for(auto it:s){
int hold=it-'a';
if(nxt[cur][hold]==0){
nxt[cur][hold]=ptr++;
}
cur=nxt[cur][hold];
val[cur][1]=true;
}
}
bool hold=dp(1,1);
if(hold) cout << "Nina\n";
else cout << "Emilija\n";
}
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("in.txt","r",stdin);
//freopen("in.txt","w",stdout);
int t=1;
//cin >> t;
while(t--){
solve();
}
}
# | 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... |