Submission #520046

# Submission time Handle Problem Language Result Execution time Memory
520046 2022-01-28T08:27:17 Z HaYoungJoon Vlak (COCI20_vlak) C++14
0 / 70
16 ms 14412 KB
#include <bits/stdc++.h>

using namespace std;

int trie[200001][26], timer = 0;
int n,m;
vector<int> adj[100001];
bool WHO[100001][2];

void addString(string s, bool who) {
    int cur = 0;
    for (char c: s) {
        if (trie[cur][c-'a'] == 0) {
            adj[cur].emplace_back(++timer);
            trie[cur][c-'a'] = timer;
        }
        WHO[trie[cur][c-'a']][who] = 1;
        cur = trie[cur][c-'a'];
    }
}

bool DFS(int u, int cur) {
    if (cur == 0 && !WHO[u][0]) return 0;
    if (cur == 1 && !WHO[u][1]) return 1;
    for (int v: adj[u])
        if (WHO[v][cur]) {
            bool check = DFS(v,cur ^ 1);
            if (cur == 0 && check) return 1;
            if (cur == 1 && !check) return 0;
        }
    return cur;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s;
        addString(s,0);
    }
    cin >> m;
    for (int i = 1; i <= m; i++) {
        cin >> s;
        addString(s,1);
    }
    for (int u: adj[0]) {
        if (WHO[u][0] && DFS(u,1)) {
            cout << "Alice";
            return 0;
        }
    }
    cout << "Bob";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 13960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 14412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 13708 KB Output isn't correct
2 Halted 0 ms 0 KB -