# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405681 | souvenir_vayne | Vlak (COCI20_vlak) | C++14 | 25 ms | 23244 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;
struct trie {
trie *a[26];
bool can[26];
int sz = 0;
};
trie *x = new trie();
bool dfs(trie *u) {
bool ans = (u->sz) & 1;
ans = !ans;
for(int i = 0; i < 26; i++) {
if(!(u->can[i])) continue;
if( (u->sz & 1) ) {
ans = max(ans, dfs(u->a[i]));
if(ans)
return 1;
}
else {
ans = min(ans, dfs(u->a[i]));
if(!ans)
return 0;
}
}
return ans;
}
int32_t main() {
int n;
cin >> n;
while(n--) {
string s;
cin >> s;
trie *aux = x;
for(int i = 0; i < s.size(); i++) {
if(aux->a[s[i] - 'a'] == NULL)
aux->a[s[i] - 'a'] = new trie();
if(i%2 == 0)
aux->can[s[i] - 'a'] = 1;
aux = aux->a[s[i] - 'a'];
aux->sz = i+1;
}
}
cin >> n;
while(n--) {
string s;
cin >> s;
trie *aux = x;
for(int i = 0; i < s.size(); i++) {
if(aux->a[s[i] - 'a'] == NULL)
aux->a[s[i] - 'a'] = new trie();
if(i & 1)
aux->can[s[i] - 'a'] = 1;
aux = aux->a[s[i] - 'a'];
aux->sz = i+1;
}
}
cout << (dfs(x) ? "Emilija" : "Nina") << 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... |