# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1188291 | SmuggingSpun | Vlak (COCI20_vlak) | C++20 | 11 ms | 15524 KiB |
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
struct Node{
int child[26];
Node(){
memset(this->child, -1, sizeof(this->child));
}
};
struct Trie{
vector<Node>trie;
Trie(){
trie.emplace_back(Node());
}
void insert(const string& s){
int root = 0;
for(const char& c : s){
int nxt = c - 97;
if(trie[root].child[nxt] == -1){
trie[root].child[nxt] = trie.size();
trie.emplace_back(Node());
}
root = trie[root].child[nxt];
}
}
};
Trie a, b;
bool play(int ra, int rb, bool lvl){
if(lvl){
if(ra == -1){
return false;
}
for(int i = 0; i < 26; i++){
int nxt = a.trie[ra].child[i];
if(nxt != -1 && !play(nxt, b.trie[rb].child[i], !lvl)){
return true;
}
}
return false;
}
if(rb == -1){
return false;
}
for(int i = 0; i < 26; i++){
int nxt = b.trie[rb].child[i];
if(nxt != -1 && !play(a.trie[ra].child[i], nxt, !lvl)){
return true;
}
}
return false;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n;
cin >> n;
for(int i = 0; i < n; i++){
string s;
cin >> s;
a.insert(s);
}
cin >> n;
for(int i = 0; i < n; i++){
string s;
cin >> s;
b.insert(s);
}
cout << (play(0, 0, true) ? "Nina" : "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... |