#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 10;
string s[N], t[N];
struct Trie{
Trie* next[26];
int cnt;
Trie(){
cnt = 0;
for(int i = 0; i < 26; ++i) next[i] = NULL;
}
}* root;
void insert(string&, int);
bool traverse(string&, int);
int main (int argc, char const *argv[]) {
ios_base::sync_with_stdio(0);
cin.tie(0);
root = new Trie();
int n; cin >> n;
for(int i = 1; i <= n; ++i) cin >> s[i];
int m; cin >> m;
for(int i = 1; i <= n; ++i) {
cin >> t[i];
insert(t[i], t[i].length());
}
for(int i = 1; i <= n; ++i){
if(traverse(s[i], s[i].length())){
cout << "Nina";
return 0;
}
}
cout << "Emilija";
return 0;
}
void insert(string& str, int n){
Trie* node = root;
for(int i = 0; i < n; ++i){
int c = str[i] - 'a';
if(node->next[c] == NULL) node->next[c] = new Trie();
node = node->next[c];
++node->cnt;
}
}
bool traverse(string& str, int n){
Trie* node = root;
int cnt = -1;
for(int i = 0; i < n; ++i){
int c = str[i] - 'a';
if(node->next[c] == NULL) {
return !(i & 1);
}
node = node->next[c];
if(i != 0){
if(cnt != node->cnt) {
if((i & 1)) return 0;
}
}
cnt = node->cnt;
}
return n & 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12892 KB |
Output is correct |
2 |
Correct |
3 ms |
12892 KB |
Output is correct |
3 |
Correct |
3 ms |
12888 KB |
Output is correct |
4 |
Correct |
3 ms |
12892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
12892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12892 KB |
Output is correct |
2 |
Correct |
3 ms |
12892 KB |
Output is correct |
3 |
Correct |
3 ms |
12892 KB |
Output is correct |
4 |
Correct |
3 ms |
12984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
12892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23644 KB |
Output is correct |
2 |
Correct |
10 ms |
22964 KB |
Output is correct |
3 |
Incorrect |
11 ms |
22620 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
23644 KB |
Output is correct |
2 |
Correct |
10 ms |
24564 KB |
Output is correct |
3 |
Correct |
10 ms |
23388 KB |
Output is correct |
4 |
Correct |
9 ms |
23388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
23128 KB |
Output is correct |
2 |
Correct |
10 ms |
23132 KB |
Output is correct |
3 |
Incorrect |
10 ms |
23388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |