Submission #965360

# Submission time Handle Problem Language Result Execution time Memory
965360 2024-04-18T11:35:16 Z dosts Vlak (COCI20_vlak) C++17
70 / 70
21 ms 20060 KB
//Dost SEFEROĞLU
#pragma GCC optimize("O3,unroll-loops,Ofast")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " << 
#define vi vector<int>
const int N = 5e5+100,inf = 1e9,MOD = 1e9+7;

int add(int x,int y) {
    return ((x+y) >= MOD ? x+y-MOD : x+y);
}

string S;

struct Trie {
    unordered_map<int,Trie*> children;
    int ultimo[2] = {0,0};
    void insert(string* ss,int fl) {
        ultimo[fl]++;
        if (ss->empty()) return;
        char cc = ss->back();
        ss->pop_back();
        if (!children.count(cc)) children[cc] = new Trie;
        children[cc]->insert(ss,fl);
    }

    bool dfs(int turn) {
        for (auto it : children){
            if (!it.ss->ultimo[turn]) continue;
            if (!it.ss->dfs(1-turn)) return true;
        }
        return false;
    }

} *root = new Trie;


void solve() {
    int n;
    cin >> n;
    for (int i=1;i<=n;i++) {
        cin >> S;
        reverse(S.begin(),S.end());
        root->insert(&S,0);
    }
    int m;
    cin >> m;
    for (int i=1;i<=m;i++) {
        cin >> S;
        reverse(S.begin(),S.end());
        root->insert(&S,1);
    }

    cout << (root->dfs(0) ? "Nina\n" : "Emilija\n");
}
                 
                             
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef Dodi
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 18008 KB Output is correct
2 Correct 19 ms 16988 KB Output is correct
3 Correct 18 ms 16084 KB Output is correct
4 Correct 20 ms 17496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 19288 KB Output is correct
2 Correct 19 ms 20060 KB Output is correct
3 Correct 19 ms 18564 KB Output is correct
4 Correct 19 ms 18696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 17752 KB Output is correct
2 Correct 18 ms 17244 KB Output is correct
3 Correct 20 ms 17720 KB Output is correct
4 Correct 21 ms 19036 KB Output is correct