#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define pii pair<int,int>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 2e5;
const int SZ = 26;
char INIT = 'a';
struct Node {
int isA = 0 , isB = 0 , fw = 0 , sw = 0;
Node* next[SZ] = {};
};
struct Trie { //init->Trie T
Node* root;
Trie() {root = new Node();}
void insert(const string &s , int pl) {
Node* curr = root;
for (char c : s) {
int id = c - INIT;
if (!curr->next[id])
curr->next[id] = new Node();
curr = curr->next[id];
curr->isA |= pl == 0;
curr->isB |= pl == 1;
}
}
void dfs(int from,Node* curr) {
if (curr->isA)curr->fw = 1;
if (curr->isB)curr->sw = 1;
for (int i = 0; i < 26; i++) {
if (curr->next[i]) {
dfs(i , curr->next[i]);
curr->fw &= (1 - curr->next[i]->sw);
curr->sw &= (1 - curr->next[i]->fw);
}
}
}
};
void solve(int tc) {
Trie T;
int n; cin >> n;
while (n--) {
string s; cin >> s;
T.insert(s , 0);
}
int m; cin >> m;
while (m--) {
string s; cin >> s;
T.insert(s , 1);
}
T.dfs(-1,T.root);
for (int i = 0; i < 26; i++) {
if (T.root->next[i] and T.root->next[i]->fw) {
cout << "Nina" << endl;
return;
}
}
cout << "Emilija" << endl;
}
int32_t main() {
FAST
int t = 1;
// cin >> t;
for (int tc = 1; tc <= t; tc++)
solve(tc);
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... |