#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 2e5+5;
int tr[N][26], win[N], p[N][2], cnt = 0;
void insert(string &s, int player){
int now = 0;
for(auto c : s){
if(!tr[now][c-'a']) now = tr[now][c-'a'] = ++cnt;
else now = tr[now][c-'a'];
}
p[now][player] = 1;
}
void dfs(int now, int turn = 0){
bool has = 0, ok = 0;
for(int i = 0;i < 26;i++){
if(!tr[now][i]) continue;
dfs(tr[now][i]);
ok = 1;
if(!win[tr[now][i]]) has = 1;
}
if(!ok){
if(p[now][turn]) win[now] = 1;
}
if(has) win[now] = 1;
}
signed main(){
fastio
int n;
cin >> n;
for(int i = 0;i < n;i++){
string s;
cin >> s;
insert(s,0);
}
int m;
cin >> m;
for(int i = 0;i < m;i++){
string s;
cin >> s;
insert(s,1);
}
dfs(0);
cout << (win[0] ? "Nina" : "Emilija") << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
620 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
620 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
620 KB |
Output is correct |
4 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
620 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
620 KB |
Output is correct |
4 |
Correct |
1 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
19820 KB |
Output is correct |
2 |
Incorrect |
28 ms |
18668 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
20352 KB |
Output is correct |
2 |
Correct |
26 ms |
21228 KB |
Output is correct |
3 |
Correct |
24 ms |
19564 KB |
Output is correct |
4 |
Correct |
24 ms |
19820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
19180 KB |
Output is correct |
2 |
Incorrect |
25 ms |
18668 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |