This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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;
| ~~~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |