# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
961966 | rnazymxan | Vlak (COCI20_vlak) | C++17 | 16 ms | 22620 KiB |
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<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
#define ll long long
void init_code(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
const int N = 1e5 + 11;
struct Node {
Node* node[26];
Node(){
for(int i = 0; i < 26; i++){
node[i] = NULL;
}
}
};
void add(Node* root, string s){
int ptr = 0;
int n = s.size();
while(ptr < n){
if(root->node[s[ptr] - 'a'] != NULL){
root = root->node[s[ptr] - 'a'];
}else{
root->node[s[ptr] - 'a'] = new Node();
root = root->node[s[ptr] - 'a'];
}
ptr++;
}
}
bool win(Node* trie1, Node* trie2){
for(int i = 0; i < 26; i++){
if(trie1->node[i] != NULL && trie2->node[i] == NULL){
return true;
}
}
bool hehe = false;
for(int i = 0; i < 26; i++){
if(trie1->node[i] != NULL){
hehe |= !win(trie2 -> node[i], trie1 -> node[i]);
}
}
return hehe;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// init_code();
int n;
string s;
cin >> n;
Node *trie1 = new Node();
Node *trie2 = new Node();
while(n--){
cin >> s;
add(trie1, s);
}
cin >> n;
while(n--){
cin >> s;
add(trie2, s);
}
if(win(trie1, trie2)){
cout << "Nina";
}else{
cout << "Emilija";
}
}
Compilation message (stderr)
# | 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... |