#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <vector>
using namespace std;
typedef long long int ll;
const int maxn = 1e6;
ll n, m; // Nina = 0, Emi = 1
struct Vertex{
ll next[26];
ll mask = 0;
ll output = 0;
Vertex()
{
fill(begin(next), end(next), -1);
}
};
Vertex trie[maxn];
ll cnt = 1;
void add_trie(string s, int bit)
{
int u = 0;
for(auto c : s)
{
trie[u].mask |= (1 << bit);
if(trie[u].next[c - 'a'] == -1)
{
trie[u].next[c - 'a'] = cnt++;
}
u = trie[u].next[c - 'a'];
}
trie[u].mask |= (1 << bit);
trie[u].output++;
}
int dfs_trie(int u, int bit)
{
for(int i = 0; i <= 25; i++)
{
int chi = trie[u].next[i];
if(trie[u].next[i] == -1)
continue;
if((trie[chi].mask&(1LL << (bit^1))) && dfs_trie(chi, bit^1))
return 0;
}
return 1;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++)
{
string s;
cin >> s;
add_trie(s, 0); // Nina
}
cin >> m;
for(int i = 1; i <= m; i++)
{
string s;
cin >> s;
add_trie(s, 1); // Emi
}
trie[0].mask |= (1 << 1);
if(!dfs_trie(0, 0))
cout << "Nina";
else
cout << "Emilija";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
219468 KB |
Output is correct |
2 |
Correct |
76 ms |
219480 KB |
Output is correct |
3 |
Incorrect |
82 ms |
219448 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
219432 KB |
Output is correct |
2 |
Correct |
78 ms |
219484 KB |
Output is correct |
3 |
Incorrect |
78 ms |
219392 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
77 ms |
219464 KB |
Output is correct |
2 |
Incorrect |
79 ms |
219392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
219468 KB |
Output is correct |
2 |
Correct |
77 ms |
219444 KB |
Output is correct |
3 |
Correct |
77 ms |
219360 KB |
Output is correct |
4 |
Correct |
83 ms |
219400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
82 ms |
219424 KB |
Output is correct |
2 |
Incorrect |
86 ms |
219476 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
81 ms |
219396 KB |
Output is correct |
2 |
Incorrect |
95 ms |
219432 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
82 ms |
219360 KB |
Output is correct |
2 |
Incorrect |
82 ms |
219372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |