답안 #439464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439464 2021-06-30T04:49:00 Z ldn694 Vlak (COCI20_vlak) C++17
70 / 70
22 ms 20164 KB
#include <bits/stdc++.h>
#define fu(i, a, b) for (int i = a; i <= b; i++)
#define fd(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
const int N = 2e5 + 10;
int num[2];
struct Node
{
    Node *child[26];
    bool ticket[2];
    Node()
    {
        fu(i, 0, 25) child[i] = NULL;
        fu(i, 0, 1) ticket[i] = false;
    }
};
Node *root;
void Insert(const string &a, int o)
{
    Node *pos = root;
    for (char x : a)
    {
        int v = int(x) - 97;
        if (pos->child[v] == NULL) pos->child[v] = new Node();
        pos->child[v]->ticket[o] = true;
        pos = pos->child[v];
    }
}
bool win(Node *u, int o)
{
    bool passed = false;
    fu(i, 0, 25)
    {
        if (u->child[i] == NULL) continue;
        if (!u->child[i]->ticket[o]) continue;
        passed |= !win(u->child[i], 1 - o);
        if (passed) break;
    }
    return passed;
}
int main()
{
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    root = new Node();
    fu(i, 0, 1)
    {
        cin >> num[i];
        fu(j, 1, num[i])
        {
            string s;
            cin >> s;
            Insert(s, i);
        }
    }
    cout << (win(root, 0) ? "Nina" : "Emilija");
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 18956 KB Output is correct
2 Correct 17 ms 17756 KB Output is correct
3 Correct 18 ms 16760 KB Output is correct
4 Correct 20 ms 18368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 19276 KB Output is correct
2 Correct 18 ms 20164 KB Output is correct
3 Correct 17 ms 18756 KB Output is correct
4 Correct 22 ms 18888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 18268 KB Output is correct
2 Correct 16 ms 17740 KB Output is correct
3 Correct 16 ms 18332 KB Output is correct
4 Correct 19 ms 19372 KB Output is correct