# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1274166 | dhuyyyy | Vlak (COCI20_vlak) | C++20 | 1 ms | 1860 KiB |
#include<bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using aa = array<int,4>;
const int N = 2e5+5;
const int INF = 1e9;
const int MOD = 998244353;
int n, m, u, timer = 0;
int trie[2][N][27], dp[N];
string s;
void add(string s,int type){
u = 0;
for (char c : s){
if (trie[type][u][c - 'a'] == 0) trie[type][u][c - 'a'] = ++timer;
u = trie[type][u][c - 'a'];
}
}
int dfs(int u,int v, int turn){
if (dp[u] != -1) return dp[u];
for (int j = 0; j <= 25; j++){
if (trie[turn][u][j] && !trie[turn^1][v][j]){
dp[u] = turn;
break;
}
}
for (int j = 0; j <= 25; j++){
if (trie[turn][u][j]){
int tmp = dfs(trie[0][u][j],trie[1][v][j],turn ^ 1);
if (tmp == turn){
dp[u] = turn;
return dp[u];
} else dp[u] = tmp;
}
}
return dp[u];
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
cin >> n;
for (int i = 1; i <= n; i++){
cin >> s;
add(s,0);
}
cin >> m;
timer = 0;
for (int i = 1; i <= m; i++){
cin >> s;
add(s,1);
}
for (int i = 0; i < 200000; i++) dp[i] = -1;
cout << (dfs(0,0,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... |