Submission #448720

# Submission time Handle Problem Language Result Execution time Memory
448720 2021-08-01T01:47:08 Z 2548631 Vlak (COCI20_vlak) C++17
70 / 70
21 ms 21580 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL)
#define forw(i, l, r) for( int i = (l) ; i < (r) ; i++ )
#define forb(i, r, l) for( int i = (r) ; i >= (l) ; i-- )
#define log2i(x) (64 - __builtin_clzll(1ll * (x)) - 1)
#define numBit(x) (__builtin_popcountll(1ll * (x)))
#define getBit(x, i) ((x) >> (i) & 1)
#define Pi acos(-1.0l)
#define sz(x) int(x.size())
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define debug(x) cerr << #x << " = " << x << '\n';

const int N = 2e5 + 7;
int n, m, numNode = 1;
int nxt[N][26], dp[N], fav[N];

void add(string s, int v) {
    int r = 0;
    forw(i, 0, sz(s)) {
        if(nxt[r][s[i] - 'a'] == -1)  nxt[r][s[i] - 'a'] = numNode++;
        r = nxt[r][s[i] - 'a'];
    }
    fav[r] |= 1 << v;
}

void dfs(int u, int r = 0) {
    dp[u] = 0;
    forw(i, 0, 26) {
        int v = nxt[u][i];
        if(v == -1) continue;
        dfs(v, 1 - r);
        fav[u] |= fav[v];
        if(getBit(fav[v], r)) dp[u] |= 1 - dp[v];
    }
}

int main() {
    fastIO;
#ifndef ONLINE_JUDGE
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
#endif

    memset(nxt, -1, sizeof nxt);
    cin >> n;
    forw(i, 0, n) {
        string st; cin >> st;
        add(st, 0);
    }
    cin >> m;
    forw(i, 0, m) {
        string st; cin >> st;
        add(st, 1);
    }

    dfs(0);
    cout << (dp[0] ? "Nina" : "Emilija");
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 20556 KB Output is correct
2 Correct 9 ms 20684 KB Output is correct
3 Correct 9 ms 20632 KB Output is correct
4 Correct 9 ms 20684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 20684 KB Output is correct
2 Correct 9 ms 20672 KB Output is correct
3 Correct 9 ms 20632 KB Output is correct
4 Correct 9 ms 20672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 20608 KB Output is correct
2 Correct 9 ms 20672 KB Output is correct
3 Correct 9 ms 20684 KB Output is correct
4 Correct 9 ms 20684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 20672 KB Output is correct
2 Correct 10 ms 20684 KB Output is correct
3 Correct 9 ms 20576 KB Output is correct
4 Correct 9 ms 20684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 21544 KB Output is correct
2 Correct 19 ms 21440 KB Output is correct
3 Correct 21 ms 21392 KB Output is correct
4 Correct 20 ms 21452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 21452 KB Output is correct
2 Correct 18 ms 21580 KB Output is correct
3 Correct 18 ms 21512 KB Output is correct
4 Correct 17 ms 21452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 21524 KB Output is correct
2 Correct 18 ms 21412 KB Output is correct
3 Correct 21 ms 21452 KB Output is correct
4 Correct 20 ms 21524 KB Output is correct