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;
int n, m;
string s;
struct node
{
int w;
node* p[26];
node() {
w=0;
for (int i=0; i<26; i++) p[i]=0;
}
};
typedef node* pnode;
pnode rt1=new node(), rt2=new node();
void build(pnode &k, int idx, int sz)
{
if (idx==sz) return;
if (!(k->p[s[idx]-'a'])) k->p[s[idx]-'a']=new node();
build(k->p[s[idx]-'a'], idx+1, sz);
}
void solve(pnode l, pnode r)
{
for (int i=0; i<26; i++) if (l->p[i]&&!(r->p[i])) return l->w=1, void();
for (int i=0; i<26; i++) if (l->p[i]) solve(r->p[i], l->p[i]), l->w|=!(r->p[i]->w);
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=0; i<n; i++) cin>>s, build(rt1, 0, s.size());
cin>>m;
for (int i=0; i<m; i++) cin>>s, build(rt2, 0, s.size());
solve(rt1, rt2);
if (rt1->w) cout<<"Nina";
else cout<<"Emilija";
}
# | 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... |