#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define getar(ar,n) for(ll i=0;i<n;++i) cin>>ar[i]
#define show(n) cout<<n<<'\n'
#define all(v) v.begin(), v.end()
#define br cout<<"\n"
#define pb push_back
#define nl '\n'
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ret return
#define ll long long
#define ld long double
#define sza(x) ((int)x.size())
const int mxN = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;
struct Node
{
Node* child[26];
bool n,m;
Node(){
for(ll i=0;i<26;++i) child[i]=0;
n=m=0;
}
};
Node* root = new Node();
struct Trie{
void add(string str,bool f){
Node* curr=root;
for(auto it:str){
if(curr->child[it-'a']==NULL) curr->child[it-'a']=new Node();
curr=curr->child[it-'a'];
curr->n|=f;
curr->m|=!f;
}
}
bool qry(Node* curr,bool f){
for(ll i=0;i<26;++i){
if(curr->child[i]!=NULL&&curr->child[i]->n==f&&curr->child[i]->m==!f){
return f;
}
if(curr->child[i]!=NULL&&curr->child[i]->n==curr->child[i]->m&&qry(curr->child[i],!f)==f){
return f;
}
}
return !f;
}
} tr;
void solve() {
ll n;cin>>n;
string str;
for(ll i=0;i<n;++i){
cin>>str;
tr.add(str,1);
}
cin>>n;
for(ll i=0;i<n;++i){
cin>>str;
tr.add(str,0);
}
if(tr.qry(root,1)) show("Nina");
else show("Emilija");
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
608 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
608 KB |
Output is correct |
4 |
Correct |
1 ms |
608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
608 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
608 KB |
Output is correct |
4 |
Correct |
1 ms |
608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
608 KB |
Output is correct |
2 |
Correct |
1 ms |
608 KB |
Output is correct |
3 |
Correct |
1 ms |
608 KB |
Output is correct |
4 |
Correct |
1 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
608 KB |
Output is correct |
2 |
Correct |
1 ms |
608 KB |
Output is correct |
3 |
Correct |
1 ms |
476 KB |
Output is correct |
4 |
Correct |
1 ms |
608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
19300 KB |
Output is correct |
2 |
Correct |
17 ms |
18168 KB |
Output is correct |
3 |
Correct |
16 ms |
16992 KB |
Output is correct |
4 |
Correct |
18 ms |
18708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
19552 KB |
Output is correct |
2 |
Correct |
18 ms |
20588 KB |
Output is correct |
3 |
Correct |
16 ms |
18740 KB |
Output is correct |
4 |
Correct |
21 ms |
19080 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
18528 KB |
Output is correct |
2 |
Correct |
15 ms |
18028 KB |
Output is correct |
3 |
Correct |
17 ms |
18516 KB |
Output is correct |
4 |
Correct |
17 ms |
19808 KB |
Output is correct |