#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
using namespace std;
#define fast_io ios::sync_with_stdio(0), cin.tie(0)
#define vi vector<int>
#define pi pair<int, int>
#define fv first
const int N = 2e5+7, K = 26;
pi adj[N][K]; int len;
void add(string& s, int d) {
int x = 0;
for(char ch: s) {
int c = ch-'a';
auto [y, f] = adj[x][c];
if(y) f += d; else
adj[x][c] = {len++, d};
x = adj[x][c].fv;
}
}
int dfs(int x, int r) {
int wx = 0;
for(auto [y, f]: adj[x]) {
if(!y) continue;
if(r&1) {
if(f > -1) {
int wy = dfs(y, r^1);
wx |= wy^1;
}
} else {
if(f < 1) {
int wy = dfs(y, r^1);
wx |= wy^1;
}
}
}
return wx;
}
int main() {
fast_io;
len = 1;
int n; string s;
for(int k = -1; k < 2; k++) {
if(!k) continue;
cin >> n;
for(int i = 0; i < n; i++) {
cin >> s;
add(s, k);
}
}
int ret = dfs(0, 0);
cout << (ret? "Nina": "Emilija") << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
17756 KB |
Output is correct |
2 |
Incorrect |
11 ms |
16644 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
18268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
17240 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |