This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int ABC = 28;
const int MAXN = 1000010;
struct Node {
int state;
Node *child[ABC];
Node() {
state = 0;
for (int i=0; i<ABC; i++) child[i] = NULL;
}
};
int cnt;
Node nodes[MAXN * 2];
Node *newNode() {
return &nodes[cnt++];
}
struct Trie {
Node *root;
Trie() {
root = newNode(); //points to the address of nodes[cnt]
}
void insert(Node *node, string &s, int pos, int mask) {
if (pos == (int)s.size()) {
return;
}
node->state |= mask;
if (!node->child[s[pos] - 'a']) {
node->child[s[pos] - 'a'] = newNode();
}
insert(node->child[s[pos] - 'a'], s, pos + 1, mask);
}
int solve(Node *node, int turn) {
if (!(node->state & (1 << turn))) {
return 0;
}
for (int i = 0; i < ABC; i++) {
if (node->child[i] && !solve(node->child[i], turn ^ 1)) {
return 1;
}
}
return 0;
}
};
Trie T;
const string ans[] = {"Emilija", "Nina"};
int main() {
for (int i = 0; i < 2; i++) {
int n;
string s;
cin >> n;
for (int j = 0; j < n; j++) {
cin >> s;
T.insert(T.root, s, 0, (1 << i));
}
}
cout << ans[T.solve(T.root, 0)] << endl;
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... |