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 <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";
}
# | 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... |