Submission #390500

# Submission time Handle Problem Language Result Execution time Memory
390500 2021-04-16T08:12:40 Z ngpin04 Vlak (COCI20_vlak) C++14
70 / 70
11 ms 10792 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
const int N = 2e5 + 5;
 
int ptr[2][N][26];
int n, node;
 
bool Win[N];
 
void add(string &s, int id) {
    int cur = 0;
    for (char c : s) {
        int &p = ptr[id][cur][c - 'a'];
        if (p == 0)
            p = ++node;
        cur = p;
    }
}
 
bool solve(int i, int j, int cur) {
    bool res = false;
 
    for (int val = 0; val < 26; val++) {
        int pcur = ptr[cur][i][val];
        if (pcur == 0)
            continue;
 
        int pnxt = ptr[cur ^ 1][j][val];
        if (pnxt == 0)
            return true;
        res |= !solve(pnxt, pcur, cur ^ 1);
    }
    return res;
}
 
void proc() { cout << (solve(0, 0, 0) ? ("Nina\n") : ("Emilija\n")); }
 
void enter() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        add(s, 0);
    }
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        add(s, 1);
    }
}
 
void preproc() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // freopen("KARA.inp","r",stdin);
    // freopen("KARA.out","w",stdout);
}
 
int main() {
    preproc();
    enter();
    proc();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9888 KB Output is correct
2 Correct 10 ms 9292 KB Output is correct
3 Correct 10 ms 9036 KB Output is correct
4 Correct 10 ms 9840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 10060 KB Output is correct
2 Correct 10 ms 10792 KB Output is correct
3 Correct 9 ms 9916 KB Output is correct
4 Correct 9 ms 10068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9548 KB Output is correct
2 Correct 10 ms 9548 KB Output is correct
3 Correct 10 ms 9740 KB Output is correct
4 Correct 11 ms 10280 KB Output is correct