# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1014126 | vjudge1 | Vlak (COCI20_vlak) | C++17 | 9 ms | 12124 KiB |
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>
#define ll long long
#define pii pair <int, int>
using namespace std;
const int siz = 28;
const int N = 2e6 + 10;
const int M = 2e5 + 10;
struct node {
int ch[siz];
int vis[2], sum[2];
} trie[N];
char c[M];
bool fg[N];
int rt = 0, ncnt = 0;
inline void insert(char *s, int who) {
int p = rt;
for (int i = 0; s[i]; ++i) {
int j = s[i] - 'a';
if (!trie[p].ch[j]) trie[p].ch[j] = ++ncnt;
p = trie[p].ch[j];
trie[p].sum[who] ++;
}
trie[p].vis[who] ++;
}
inline void solve(int p, int who) {
for (int i = 0; i < siz; ++i) {
if (trie[p].ch[i]) {
solve(trie[p].ch[i], who ^ 1);
if (trie[trie[p].ch[i]].sum[who] > 0) {
if (!fg[trie[p].ch[i]]) {
fg[p] = true;
return ;
}
}
}
}
fg[p] = false;
}
int main() {
int n, m; scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%s", c);
insert(c, 0);
}
scanf("%d", &m);
for (int i = 1; i <= m; ++i) {
scanf("%s", c);
insert(c, 1);
}
solve(0, 0);
if (fg[0]) printf("Nina");
else printf("Emilija");
//11 11 11 11 11 11 Yeah
return 0;
}
Compilation message (stderr)
# | 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... |