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<map>
using namespace std;
struct Node {
bool num = false;
map<char, Node*> next;
};
void add(Node* root, string s) {
for(char c : s) {
if(root->next.find(c) == root->next.end())
root->next[c] = new Node();
root = root->next[c];
}
root->num = true;
}
bool traverse(Node* ni, Node* em, bool move) {
if(ni->next.empty() && em->next.empty())
return move;
if(ni->next.empty())
return false;
else if(em->next.empty())
return true;
Node* ts[] = {ni, em};
for(auto p : ts[move]->next) {
if(ts[!move]->next.find(p.first) == ts[!move]->next.end())
return move;
if(traverse(ni->next[p.first], em->next[p.first], !move) == move)
return move;
}
return !move;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
Node* nina = new Node();
Node* ema = new Node();
int n, m;
string s;
cin>>n;
while(n--) {
cin>>s;
add(nina, s);
}
cin>>m;
while(m--) {
cin>>s;
add(ema, s);
}
cout<<(traverse(nina, ema, true) ? "Nina" : "Emilija")<<endl;
return 0;
}
# | 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... |