답안 #520047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
520047 2022-01-28T08:27:49 Z HaYoungJoon Vlak (COCI20_vlak) C++14
70 / 70
17 ms 14936 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 << "Nina";
            return 0;
        }
    }
    cout << "Emilija";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2764 KB Output is correct
2 Correct 2 ms 2792 KB Output is correct
3 Correct 2 ms 2764 KB Output is correct
4 Correct 1 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2764 KB Output is correct
2 Correct 2 ms 2804 KB Output is correct
3 Correct 2 ms 2804 KB Output is correct
4 Correct 2 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2764 KB Output is correct
2 Correct 2 ms 2764 KB Output is correct
3 Correct 2 ms 2764 KB Output is correct
4 Correct 2 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2764 KB Output is correct
2 Correct 2 ms 2764 KB Output is correct
3 Correct 2 ms 2808 KB Output is correct
4 Correct 2 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 13772 KB Output is correct
2 Correct 14 ms 13316 KB Output is correct
3 Correct 14 ms 12620 KB Output is correct
4 Correct 15 ms 13680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 14284 KB Output is correct
2 Correct 15 ms 14936 KB Output is correct
3 Correct 13 ms 14028 KB Output is correct
4 Correct 17 ms 14160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 13508 KB Output is correct
2 Correct 13 ms 13388 KB Output is correct
3 Correct 14 ms 13696 KB Output is correct
4 Correct 14 ms 14412 KB Output is correct