답안 #544413

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544413 2022-04-01T21:27:15 Z DragosC1 Vlak (COCI20_vlak) C++17
70 / 70
21 ms 12948 KB
#include <iostream>
#include <map>
using namespace std;

struct trie {
    map<int, trie*> lit;
    trie() {
        lit.clear();
    }
};

trie *root1, *root2;
string s;

void add(int ind, trie *node) {
    if (ind == s.size())
        return;
    int l = s[ind] - 'a';
    if (node->lit[l] == 0)
        node->lit[l] = new trie();
    add(ind + 1, node->lit[l]);
}

bool sch(trie *node1, trie *node2, int ind) {
    bool rez = 0;
    if (ind % 2 == 0)
        for (auto it = node1->lit.begin(); it != node1->lit.end(); it++)
            if (node2->lit[it->first] == 0) {
                rez = 1;
                break;
            }
            else {
                bool x = sch(node1->lit[it->first], node2->lit[it->first], ind + 1);
                rez |= (1 - x);
            }
    else
        for (auto it = node2->lit.begin(); it != node2->lit.end(); it++)
            if (node1->lit[it->first] == 0) {
                rez = 1;
                break;
            }
            else {
                bool x = sch(node1->lit[it->first], node2->lit[it->first], ind + 1);
                rez |= (1 - x);
            }
    return rez;
}

int main() {
    int i, n, m;
    root1 = new trie();
    root2 = new trie();
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> s;
        add(0, root1);
    }
    cin >> m;
    for (i = 1; i <= m; i++) {
        cin >> s;
        add(0, root2);
    }
    if (sch(root1, root2, 0))
        cout << "Nina";
    else cout << "Emilija";
    return 0;
}

Compilation message

Main.cpp: In function 'void add(int, trie*)':
Main.cpp:16:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     if (ind == s.size())
      |         ~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 12168 KB Output is correct
2 Correct 20 ms 11308 KB Output is correct
3 Correct 18 ms 10704 KB Output is correct
4 Correct 19 ms 11752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 12284 KB Output is correct
2 Correct 18 ms 12948 KB Output is correct
3 Correct 18 ms 11860 KB Output is correct
4 Correct 17 ms 11988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 11732 KB Output is correct
2 Correct 17 ms 11348 KB Output is correct
3 Correct 18 ms 11696 KB Output is correct
4 Correct 19 ms 12500 KB Output is correct