# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
689440 | MON | Vlak (COCI20_vlak) | C++14 | 26 ms | 20388 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 <iostream>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
struct Trie
{
bool e[2]; bool dp; int depth = 0;
Trie *next[26];
void baga(string &s,int p,int c)
{
e[c] = 1;
if(p == s.size()) return;
if(!next[s[p] - 'a'])
{
next[s[p] - 'a'] = new Trie;
next[s[p] - 'a']->depth = depth + 1;
}
next[s[p] - 'a']->baga(s,p + 1,c);
}
void din()
{
if(e[0] != e[1])
{
dp = e[0];
return;
}
for(int l = 0 ; l < 26 ; l++)
{
if(!next[l]) continue;
next[l]->din();
}
if(depth & 1)
{
for(int l = 0 ; l < 26 ; l++)
{
if(!next[l]) continue;
if(!next[l]->dp)
{
dp = 0;
return;
}
}
dp = 1;
}
else
{
for(int l = 0 ; l < 26 ; l++)
{
if(!next[l]) continue;
if(next[l]->dp)
{
dp = 1;
return;
}
}
dp = 0;
}
}
};
int main()
{
int n,m;
cin >> n ; string s;
Trie *trie = new Trie;
while(n--)
{
cin >> s;
trie->baga(s,0,0);
}
cin >> m;
while(m--)
{
cin >> s;
trie->baga(s,0,1);
}
trie->din();
string ans = trie->dp ? "Nina" : "Emilija";
cout << ans;
}
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... |