# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
635255 |
2022-08-25T18:18:42 Z |
ojoConmigo |
Vlak (COCI20_vlak) |
C++17 |
|
17 ms |
20436 KB |
#include <bits/stdc++.h>
using namespace std;
struct Trie{
struct Trie *child[26];
bool b[2]; //nina-0 emilija-1
char letra;
};
struct Trie *createNode(char letra){
struct Trie *nodo = new Trie;
for(int i=0; i<26; i++){
nodo->child[i] = NULL;
}
nodo->b[0] = false; nodo->b[1] = false;
nodo->letra = letra;
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(key[i]);
}
curr = curr->child[index];
curr->b[turno] = true;
}
}
bool gana(struct Trie *root,int turno){
struct Trie *curr = root;
for(int i=0; i<26; i++){
if(curr->child[i]){
struct Trie *sig = curr->child[i];
if(sig->b[1-turno]){
if(gana(sig,1-turno)){
return false;
}
}
}
}
return true;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
struct Trie *root = createNode('0');
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 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
580 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
0 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
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 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
18900 KB |
Output is correct |
2 |
Correct |
17 ms |
17648 KB |
Output is correct |
3 |
Correct |
13 ms |
16872 KB |
Output is correct |
4 |
Correct |
15 ms |
18688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
19324 KB |
Output is correct |
2 |
Correct |
15 ms |
20436 KB |
Output is correct |
3 |
Correct |
13 ms |
18796 KB |
Output is correct |
4 |
Correct |
13 ms |
19148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
18204 KB |
Output is correct |
2 |
Correct |
13 ms |
17720 KB |
Output is correct |
3 |
Correct |
14 ms |
18472 KB |
Output is correct |
4 |
Correct |
15 ms |
19688 KB |
Output is correct |