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 mxM = 2e5 + 1;
int trie[mxM][26][2], last;
void insert(string const &s, int which) {
int v = 0;
for (char ch : s) {
int c = ch - 'a';
if (!trie[v][c][which])
trie[v][c][which] = ++last;
v = trie[v][c][which];
}
}
bool dfs(array<int, 2> v, int which) {
bool ret = 0;
for (int i = 0; i < 26; ++i) {
if (trie[v[which]][i][which]) {
if (!trie[v[1-which]][i][1-which]) {
return 1;
}
ret |= !dfs({trie[v[0]][i][0], trie[v[1]][i][1]}, 1 - which);
}
}
return ret;
}
int main() {
cin.tie(0)->sync_with_stdio(false);
int N; cin >> N;
for (int i = 0; i < N; ++i) {
string s; cin >> s;
insert(s, 0);
}
cin >> N;
for (int i = 0; i < N; ++i) {
string s; cin >> s;
insert(s, 1);
}
cout << (dfs({0, 0}, 0) ? "Nina" : "Emilija");
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... |