답안 #570404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570404 2022-05-29T13:32:23 Z a_aguilo Vlak (COCI20_vlak) C++14
70 / 70
30 ms 27364 KB
#include<bits/stdc++.h>

using namespace std;

struct nodo{
    char letra;
    vector<nodo*> ady;
    nodo(char c){
        letra = c;
        ady.assign(26, NULL);
    }
};

void construct(int pos, string& S, nodo* prev){
    if(pos == S.size()) return;
    char c = S[pos];
    int n_letra = c-'a';
    if (prev->ady[n_letra] != NULL){
        construct(pos+1, S, prev->ady[n_letra]);
    }
    else{
        nodo* act = new nodo(c);
        prev->ady[n_letra] = act;
        construct(pos+1, S, act);
    }
}

bool win(nodo* Nina, nodo* Emilija, int state){
    // 1 = nina;
    // 0 = emilija;
    if(state){
        for(int i = 0; i < 26; ++i){
            if(Nina->ady[i] != NULL){
                if(Emilija->ady[i] == NULL) return true;
                if(!win(Nina->ady[i], Emilija->ady[i], 0)) return true;
            }
        }
        return false;
    }
    else{
        for(int i = 0; i < 26; ++i){
            if(Emilija->ady[i] != NULL){
                if(Nina->ady[i] == NULL) return true;
                if(!win(Nina->ady[i], Emilija->ady[i], 1)) return true;
            }
        }
        return false;
    }
}

int main(){
    int n, m;
    string S;
    nodo inicioNina = nodo('.');
    nodo inicioEmilija = nodo('.');
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> S;
        construct(0, S, &inicioNina);
    }
    cin >> m;
    for(int i = 0; i < m; ++i){
        cin >> S;
        construct (0, S, &inicioEmilija);
    }
    if(win(&inicioNina, &inicioEmilija, 1)) cout << "Nina" << endl;
    else cout << "Emilija" << endl;
    return 0;
}

Compilation message

Main.cpp: In function 'void construct(int, std::string&, nodo*)':
Main.cpp:15:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     if(pos == S.size()) return;
      |        ~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 25484 KB Output is correct
2 Correct 23 ms 23948 KB Output is correct
3 Correct 24 ms 22640 KB Output is correct
4 Correct 30 ms 24940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 26068 KB Output is correct
2 Correct 25 ms 27364 KB Output is correct
3 Correct 24 ms 25008 KB Output is correct
4 Correct 23 ms 25428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 24528 KB Output is correct
2 Correct 23 ms 24020 KB Output is correct
3 Correct 23 ms 24532 KB Output is correct
4 Correct 23 ms 26172 KB Output is correct