이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz(x) (int)x.size()
#define M(x) (1ll << (x))
#define getBit(x, i) ((x) >> (i) & 1)
#define rep(i, b, e) for (ll i = (b); i <= (e); i++)
#define rrep(i, b, e) for (ll i = (b); i >= (e); i--)
typedef long long ll;
typedef pair<ll, ll> ii;
template <class T>
bool minimize(T &a, const T &b) {
if(a > b) {a = b; return 1;}
return 0;
}
template <class T>
bool maximize(T &a, const T &b) {
if(a < b) {a = b; return 1;}
return 0;
}
const int N = 2e5 + 7;
int n, m;
string a[N], b[N];
struct node {
node *nxt[26];
bool who[2];
node() { rep(i, 0, 25) nxt[i] = nullptr; who[0] = who[1] = 0; }
};
node *rt = new node;
void ins(string s, int w) {
node *t = rt;
for (int i = 0; i < sz(s); i++) {
int id = s[i] - 'a';
if (t->nxt[id] == nullptr) t->nxt[id] = new node;
t = t->nxt[id];
t->who[w] = 1;
}
}
bool dfs(node *u, int t) {
rep(i, 0, 25) {
if (u->nxt[i] != nullptr && u->nxt[i]->who[t]) {
bool st = dfs(u->nxt[i], 1 - t);
if (!st) return 1;
}
}
return 0;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> n;
rep(i, 1, n) cin >> a[i], ins(a[i], 0);
cin >> m;
rep(i, 1, m) cin >> b[i], ins(b[i], 1);
cout << (dfs(rt, 0) ? "Nina" : "Emilija");
}
# | 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... |