#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;
#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<
#define fi first
#define sec second
#define mp make_pair
#define pb push_back
const int ABC = 28;
const int MAXN = 1000010;
struct Node {
int state;
Node *child[ABC];
Node() {
state = 0;
REP(i, ABC) child[i] = NULL;
}
};
int cnt;
Node nodes[MAXN * 2];
Node *newNode() {
return &nodes[cnt++];
}
struct Trie {
Node *root;
Trie() {
root = newNode();
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
278 ms |
454412 KB |
Output is correct |
2 |
Correct |
271 ms |
454380 KB |
Output is correct |
3 |
Correct |
276 ms |
454380 KB |
Output is correct |
4 |
Correct |
277 ms |
454508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
281 ms |
454380 KB |
Output is correct |
2 |
Correct |
272 ms |
454380 KB |
Output is correct |
3 |
Correct |
289 ms |
454380 KB |
Output is correct |
4 |
Correct |
277 ms |
454380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
274 ms |
454380 KB |
Output is correct |
2 |
Correct |
278 ms |
454380 KB |
Output is correct |
3 |
Correct |
273 ms |
454380 KB |
Output is correct |
4 |
Correct |
273 ms |
454400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
288 ms |
454380 KB |
Output is correct |
2 |
Correct |
273 ms |
454392 KB |
Output is correct |
3 |
Correct |
272 ms |
454468 KB |
Output is correct |
4 |
Correct |
274 ms |
454380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
283 ms |
454380 KB |
Output is correct |
2 |
Correct |
289 ms |
454380 KB |
Output is correct |
3 |
Correct |
289 ms |
454380 KB |
Output is correct |
4 |
Correct |
283 ms |
454332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
289 ms |
454324 KB |
Output is correct |
2 |
Correct |
289 ms |
454340 KB |
Output is correct |
3 |
Correct |
283 ms |
454380 KB |
Output is correct |
4 |
Correct |
285 ms |
454380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
286 ms |
454380 KB |
Output is correct |
2 |
Correct |
285 ms |
454380 KB |
Output is correct |
3 |
Correct |
287 ms |
454352 KB |
Output is correct |
4 |
Correct |
282 ms |
454380 KB |
Output is correct |