# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
446566 | Arinoor | Vlak (COCI20_vlak) | C++17 | 22 ms | 20428 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;
#define ios ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pai
typedef long long ll;
const int maxn = 2e5 + 10;
const int maxalpha = 26;
const int inf = 1e9 + 10;
const int mod = 1e9 + 7;
struct Trie{
struct node{
node * child[maxalpha];
bool N, E;
int h;
node(){
for(int i = 0; i < maxalpha; i ++)
child[i] = nullptr;
N = E = false;
h = 0;
}
node *getChild(int c){
if(child[c] == nullptr){
child[c] = new node();
child[c]->h = h + 1;
}
return child[c];
}
};
node * root;
Trie(){
root = new node();
}
void add(const string *s, char player){
node *cur = root;
for(char c : *s){
cur = cur->getChild(c - 'a');
if(player == 'N')
cur->N = true;
else
cur->E = true;
}
}
bool dfs(node *v){
bool fg = false;
for(int i = 0; i < maxalpha; i ++){
if(v->child[i] != nullptr){
node *u = v->child[i];
if(v->h % 2 == 0 and u->N or v->h % 2 == 1 and u->E){
if(!dfs(u))
fg = true;
}
}
}
return fg;
}
} T;
int main(){
ios;
int n;
cin >> n;
for(int i = 0; i < n; i ++){
string s;
cin >> s;
T.add(&s, 'N');
}
int m;
cin >> m;
for(int i = 0; i < m; i ++){
string s;
cin >> s;
T.add(&s, 'E');
}
if(T.dfs(T.root))
cout << "Nina\n";
else
cout << "Emilija\n";
}
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... |