#include <iostream>
#include <map>
using namespace std;
struct trie {
map<int, trie*> lit;
trie() {
lit.clear();
}
};
trie *root1, *root2;
string s;
void add(int ind, trie *node) {
if (ind == s.size())
return;
int l = s[ind] - 'a';
if (node->lit[l] == 0)
node->lit[l] = new trie();
add(ind + 1, node->lit[l]);
}
bool sch(trie *node1, trie *node2, int ind) {
if (ind % 2 == 0) {
bool rez = 0;
for (auto it = node1->lit.begin(); it != node1->lit.end(); it++)
if (node2->lit[it->first] == 0) {
rez = 1;
break;
}
else {
bool x = sch(node1->lit[it->first], node2->lit[it->first], ind + 1);
rez |= (1 - x);
}
return rez;
}
else {
bool rez = 1;
for (auto it = node2->lit.begin(); it != node2->lit.end(); it++)
if (node1->lit[it->first] == 0) {
rez = 1;
break;
}
else {
bool x = sch(node1->lit[it->first], node2->lit[it->first], ind + 1);
rez &= (1 - x);
}
if (node2->lit.size() == 0)
rez = 0;
return rez;
}
}
int main() {
int i, n, m;
root1 = new trie();
root2 = new trie();
cin >> n;
for (i = 1; i <= n; i++) {
cin >> s;
add(0, root1);
}
cin >> m;
for (i = 1; i <= m; i++) {
cin >> s;
add(0, root2);
}
if (sch(root1, root2, 0))
cout << "Nina";
else cout << "Emilija";
return 0;
}
Compilation message
Main.cpp: In function 'void add(int, trie*)':
Main.cpp:16:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | if (ind == s.size())
| ~~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
12116 KB |
Output is correct |
2 |
Incorrect |
22 ms |
11376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
12312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
11732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |