#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";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
608 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
608 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
21084 KB |
Output is correct |
2 |
Correct |
12 ms |
19952 KB |
Output is correct |
3 |
Correct |
11 ms |
18728 KB |
Output is correct |
4 |
Correct |
13 ms |
20572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
21600 KB |
Output is correct |
2 |
Correct |
13 ms |
22696 KB |
Output is correct |
3 |
Correct |
12 ms |
20828 KB |
Output is correct |
4 |
Correct |
12 ms |
21088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
20316 KB |
Output is correct |
2 |
Correct |
14 ms |
19808 KB |
Output is correct |
3 |
Correct |
12 ms |
20316 KB |
Output is correct |
4 |
Correct |
12 ms |
22260 KB |
Output is correct |