# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
595710 | tht2005 | Vlak (COCI20_vlak) | C++17 | 12 ms | 9812 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>
using namespace std;
int rd() {
bool neg = 0; char c = getchar(); for(; c < '0' || c > '9'; c = getchar()) if(c == '-') neg = !neg;
int n = 0; while('0' <= c && c <= '9') n = (n << 3) + (n << 1) + c - '0', c = getchar();
return neg ? -n : n;
}
void wr(int n) {
static char o[11];
if(n < 0) putchar('-'), n = -n;
int i = 0; do o[i++] = n % 10 + '0'; while(n /= 10);
while(i--) putchar(o[i]);
}
#define L 200005
#define V ((N) * (L))
int cnt = 1, nxt[L][26];
bool lf[2][L];
char s[L];
bool f(int v, int t) {
for(int i = 26, u; i--; ) {
u = nxt[v][i];
if(u == 0 || !lf[t][u]) {
continue;
}
if(!f(u, t ^ 1)) {
return 1;
}
}
return 0;
}
int main() {
for(int t = 0; t < 2; ++t) {
int n;
scanf("%d", &n);
for(int i = 0, l, p; i < n; ++i) {
scanf("%s", s);
l = strlen(s);
p = 0;
for(int j = 0, e; j < l; ++j) {
e = s[j] - 'a';
if(nxt[p][e] == 0) {
nxt[p][e] = cnt++;
}
p = nxt[p][e];
lf[t][p] = 1;
}
}
}
puts(f(0, 0) ? "Nina" : "Emilija");
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... |