#include <bits/stdc++.h>
using namespace std;
int a[200001][26];
int b[200001][26];
int sze1 = 0, sze2 = 0;
void insert1 (string s) {
int cur = 0;
for (auto i : s) {
if (a[cur][i - 'a'] == -1) a[cur][i - 'a'] = ++sze1;
cur = a[cur][i - 'a'];
}
}
void insert2 (string s) {
int cur = 0;
for (auto i : s) {
if (b[cur][i - 'a'] == -1) b[cur][i - 'a'] = ++sze1;
cur = b[cur][i - 'a'];
}
}
int dp[200001][2];
int ans (int x, int y, int c) {
int &ret = dp[x][c];
if (ret != -1) return ret;
ret = 0;
if (!c) {
for (int i = 0; i < 26; i++) {
if (a[x][i] != -1 && b[y][i] == -1) {
ret = 1;
} else if (a[x][i] != -1) {
ret |= !ans(a[x][i], b[y][i], 1);
}
}
} else {
for (int i = 0; i < 26; i++) {
if (b[y][i] != -1 && a[x][i] == -1) {
ret = 1;
} else if (b[y][i] != -1) {
ret |= !ans(a[x][i], b[y][i], 0);
}
}
}
return ret;
}
int main () {
memset(a, -1, sizeof(a));
memset(b, -1, sizeof(b));
memset(dp, -1, sizeof(dp));
int n;
cin >> n;
while (n--) {
string s;
cin >> s;
insert1(s);
}
cin >> n;
while (n--) {
string s;
cin >> s;
insert2(s);
}
cout << (ans(0, 0, 0) ? "Nina" : "Emilijia") << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
42584 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
42588 KB |
Output is correct |
2 |
Correct |
8 ms |
42588 KB |
Output is correct |
3 |
Correct |
6 ms |
42712 KB |
Output is correct |
4 |
Incorrect |
6 ms |
42696 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
42584 KB |
Output is correct |
2 |
Correct |
6 ms |
42588 KB |
Output is correct |
3 |
Incorrect |
6 ms |
42712 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
42588 KB |
Output is correct |
2 |
Correct |
6 ms |
42516 KB |
Output is correct |
3 |
Correct |
6 ms |
42588 KB |
Output is correct |
4 |
Incorrect |
6 ms |
42588 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
42840 KB |
Output is correct |
2 |
Incorrect |
12 ms |
42840 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
42844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
42916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |