#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
cout<<(x?"YES":"NO")<<endl;
}
int cnt=0;
struct node{
node *a[26];
int stop[3],id;
};
node *New(){
node *ret=new node;
for(int i=0;i<26;i++){
ret->a[i]=NULL;
}
ret->id=cnt++;
ret->stop[1]=ret->stop[2]=0;
return ret;
}
void insert(node *root,string s,int typ){
node *temp=root;
for(int i=0;i<(int)s.size();i++){
if(temp->a[s[i]-'a']==NULL){
temp->a[s[i]-'a']=New();
}
temp=temp->a[s[i]-'a'];
}
temp->stop[typ]=1;
}
void build(node *node){
for(int i=0;i<26;i++){
if(node->a[i]==NULL){
continue;
}
build(node->a[i]);
for(int j=1;j<=2;j++){
node->stop[j] |= node->a[i]->stop[j];
}
}
}
int dp[200005];
int solve(node *node,int i){
int &ret=dp[node->id];
if(~ret)return ret;
if(i%2==0){
ret=0;
for(int j=0;j<26;j++){
if(node->a[j]==NULL){
continue;
}
if(node->a[j]->stop[1]){
ret|=solve(node->a[j],i+1);
}
}
return ret;
}
else{
ret=0;
for(int j=0;j<26;j++){
if(node->a[j]==NULL){
continue;
}
if(node->a[j]->stop[2]){
ret|=!solve(node->a[j],i+1);
}
}
ret ^= 1;
return ret;
}
}
int main()
{
//freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
fast
node *root=New();
int n,m;
cin>>n;
for(int i=0;i<n;i++){
string s;cin>>s;
insert(root,s,1);
}
cin>>m;
for(int i=0;i<m;i++){
string s;cin>>s;
insert(root,s,2);
}
build(root);
fil(dp,-1);
cout<<(solve(root,0)?"Nina":"Emilija")<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1368 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1368 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
21128 KB |
Output is correct |
2 |
Correct |
18 ms |
20208 KB |
Output is correct |
3 |
Correct |
18 ms |
19264 KB |
Output is correct |
4 |
Correct |
21 ms |
20736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
21596 KB |
Output is correct |
2 |
Correct |
18 ms |
22620 KB |
Output is correct |
3 |
Correct |
16 ms |
20808 KB |
Output is correct |
4 |
Correct |
16 ms |
21084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
20316 KB |
Output is correct |
2 |
Correct |
16 ms |
19804 KB |
Output is correct |
3 |
Correct |
16 ms |
20316 KB |
Output is correct |
4 |
Correct |
18 ms |
21760 KB |
Output is correct |