This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |