Submission #691310

# Submission time Handle Problem Language Result Execution time Memory
691310 2023-01-31T05:02:05 Z sunshine19 Vlak (COCI20_vlak) C++14
10 / 70
14 ms 13040 KB
#include<iostream>
#include<vector>
#include<map>

using namespace std;

struct Node {
    bool num = false;
    map<char, Node*> next;

};

void add(Node* root, string s) {
    for(char c : s) {
        if(root->next.find(c) == root->next.end())
            root->next[c] = new Node();
        root = root->next[c];
    }
    root->num = true;
}

bool traverse(Node* ni, Node* em, bool move) {
    if(ni->next.empty() && em->next.empty())
        return move;

    if(ni->next.empty())
        return false;
    else if(em->next.empty())
        return true;

    Node* ts[] = {ni, em};
    for(auto p : ts[move]->next) {
        if(ts[!move]->next.find(p.first) == ts[!move]->next.end())
            return move;
        if(traverse(ni->next[p.first], em->next[p.first], !move) == move)
            return move; 
    }

    return !move; 
    
    
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    Node* nina = new Node();
    Node* ema = new Node();

    int n, m;
    string s;

    cin>>n;
    while(n--) {
        cin>>s;
        add(nina, s);
    }

    cin>>m;
    while(m--) {
        cin>>s;
        add(ema, s);
    }

    cout<<(traverse(nina, ema, true) ? "Nina" : "Emilija")<<endl;

return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Incorrect 1 ms 452 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Incorrect 1 ms 468 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 448 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 12256 KB Output is correct
2 Incorrect 14 ms 11544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 12488 KB Output is correct
2 Incorrect 13 ms 13040 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 11860 KB Output is correct
2 Incorrect 13 ms 11516 KB Output isn't correct
3 Halted 0 ms 0 KB -