# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1006575 | vjudge1 | Vlak (COCI20_vlak) | C++17 | 20 ms | 61688 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;
const int N = 2e5 + 10;
int n, m, sz = 1, nxt[3][N][26], lvl;
bool win[N];
void add(string s, int id){
int cur = 0;
for (int i = 0; i < s.size(); i ++){
char c = s[i];
int e = s[i] - 'a';
if (nxt[2][cur][e] == -1){
nxt[2][cur][e] = sz;
nxt[id][cur][e] = sz;
sz++;
}
else
nxt[id][cur][e] = nxt[2][cur][e];
// cout << cur << " -- " << c << " -- ";
cur = nxt[2][cur][e];
// cout << cur << endl;
}
}
void dfs(int v){
bool leaf = 1;
for (int e = 0; e < 26; e ++){
if (nxt[2][v][e] == -1) continue;
int u = nxt[2][v][e];
lvl++;
dfs(u);
lvl++;
if (nxt[lvl % 2][v][e] != -1){
leaf = 0;
win[v] |= !win[u];
}
}
if (leaf)
win[v] = 0;
}
int main(){
memset(nxt, -1, sizeof nxt);
cin >> n;
string s;
for (int i = 0; i < n; i ++){
cin >> s;
add(s, 0);
}
cin >> m;
for (int i = 0; i < m; i ++){
cin >> s;
add(s, 1);
}
dfs(0);
cout << (win[0] ? "Nina" : "Emilija") << endl;
}
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... |