# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
635252 |
2022-08-25T18:05:38 Z |
ojoConmigo |
Vlak (COCI20_vlak) |
C++17 |
|
16 ms |
19332 KB |
#include <bits/stdc++.h>
using namespace std;
struct Trie{
struct Trie *child[26];
bool b[2]; //nina-0 emilija-1
};
struct Trie *createNode(){
struct Trie *nodo = new Trie;
for(int i=0; i<26; i++){
nodo->child[i] = NULL;
}
nodo->b[0] = false; nodo->b[1] = false;
return nodo;
}
void insert(struct Trie *root, string key, int turno){
struct Trie *curr = root;
for(int i=0; i<(int)key.size(); i++){
int index = key[i] - 'a';
if(!curr->child[index]){
curr->child[index] = createNode();
}
struct Trie *sig = curr->child[index];
sig->b[turno] = true;
curr = curr->child[index];
}
}
bool gana(struct Trie *root,int turno){
struct Trie *curr = root;
bool noContinua = true;
for(int i=0; i<26; i++){
if(curr->child[i]){
struct Trie *sig = curr->child[i];
if(sig->b[1-turno]){
noContinua = false;
if(!gana(sig,1-turno)){
return true;
}
}
}
}
return noContinua;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
struct Trie *root = createNode();
for(int t=0; t<2; t++){
cin >> n;
for(int i=0; i<n; i++){
string s;
cin >> s;
insert(root,s,t);
}
}
bool win = false;
for(int i=0; i<26; i++){
if(root->child[i]){
struct Trie *sig = root->child[i];
if(sig->b[0]){
win = max(win,gana(sig,0));
}
}
}
if(win) cout << "Nina\n";
else cout << "Emilija\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
18964 KB |
Output is correct |
2 |
Incorrect |
14 ms |
17748 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
19332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
18260 KB |
Output is correct |
2 |
Incorrect |
16 ms |
17824 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |