Submission #1168922

#TimeUsernameProblemLanguageResultExecution timeMemory
1168922deepak16072000Vlak (COCI20_vlak)C++20
10 / 70
16 ms22340 KiB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b)for(int i=a;i<b;i++)
#define repp(x,arr) for(auto& x:arr)

#define ll              long long
#define ull              unsigned long long 
#define int ll
#define db              double
#define pb              push_back
#define all(v)             v.begin(),v.end()
#define F               first
#define S               second
#define mod              1000000007
#define popcount(x)     __builtin_popcountll(x)
#define pll             pair<ll,ll>
#define pii             pair<int,int>
#define nl              "\n"
#define PI              3.1415926536 //acos(-1.0)
#define eps 0.00000001
#define mpp                 make_pair
#define lb lower_bound
#define ub upper_bound
#define PQ priority_queue<int> //by default provide largest element;
#define RS set <ll, greater <ll> >
#define PQS priority_queue<ll,vector<ll>,greater<ll>> 
#define ZERO(a) memset(a,0,sizeof(a))
#define inf 0x3f3f3f3f


using vi = vector<int>;
using vii = vector<pii>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!
const int dxn[8]={0,1,1,1,0,-1,-1,-1},dyn[8]={1,1,0,-1,-1,-1,0,1};
template <typename A, typename B> A amax (A &a, B b){ if (b > a) a = b ; return a; }
template <typename A, typename B> A amin (A &a, B b){ if (b < a) a = b ; return a; }
template <typename A, typename B> A mod1 (A &a, B b){ a=(a%b+b)%b ; return a; }


int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
bool isleap(int by){return (by%4==0 && (by%100!=0 || by%400==0));};
inline int gcd(int x,int y){return (y==0)?x:gcd(y,x%y);}


inline int mul(int a, int b) { return (int) ((long long) (a%mod * b%mod) % mod);}
inline int add(int a,int b){return (a%mod+b%mod)%mod;}
inline int sub(int a,int b){return (a-b+mod)%mod;}
inline int binpow(int a,int b){
	a%=mod;int res=1;
while(b){if(b&1)res=res*a%mod;a=a*a%mod;b/=2;}
return res;
}

inline int inv(int a){return binpow(a,mod-2)%mod;}

struct trie{
	trie*child[26];int cnt;
	trie(){
		rep(i,0,26)child[i]=NULL;
		cnt=0;
	}
};

void insert(const string&s,trie*root){
	trie*node=root;
	for(auto ch:s){
		int id=(ch-'a');
		if(!node->child[id]){
			node->child[id]=new trie();
		}
		node=node->child[id];
		node->cnt++;
	}
}

void solve(){
  int n;cin>>n;
  trie*a=new trie();
  trie*b=new trie();
  for(int i=0;i<n;i++){
  	string s;cin>>s;insert(s,a);
  }
  int m;cin>>m;
  for(int i=0;i<m;i++){
  	string s;cin>>s;insert(s,b);
  }

  function<bool(trie*a1,trie*b1,bool)>dfs=[&](trie*a,trie*b,bool ch){
  	for(int i=0;i<26;i++){
  		if(ch){
  			if(!a->child[i] and b->child[i])return ch;
  		}else{
  			if(a->child[i] and !b->child[i])return ch;
  		}
  		if(a->child[i] and b->child[i] and dfs(a->child[i],b->child[i],1-ch)==ch)return ch;
  	}
  	return !ch;
  };
  bool ok=dfs(a,b,1);
  if(!ok)cout<<"Emilija\n";
  else cout<<"Nina\n";

}



	



int32_t main()
{
 	


   
   ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);


 
  
   int T=1;//cin >> T;
   while(T--)solve();
  


    return 0;
    
    }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...