| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 559384 | kappa | Vlak (COCI20_vlak) | C++14 | 26 ms | 23248 KiB |
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>
#define ll long long int
using namespace std;
const int maxc = 30;
struct node{
struct node* children[maxc];
bool isEnd;
int color;
};
struct node *getNode(void){
struct node *pnode = new node;
pnode->isEnd = false;
for (int i = 0; i < maxc; i++)
{
pnode->children[i] = NULL;
}
return pnode;
}
void insert(struct node* root, string key, int color){
struct node *pCrawl = root;
for (int i = 0; i < key.length(); i++)
{
pCrawl->color |= color;
int ind = key[i] - 'a';
if(!pCrawl->children[ind]){
pCrawl->children[ind] = getNode();
}
pCrawl = pCrawl->children[ind];
}
pCrawl->isEnd = true;
}
bool search(struct node* root, ll turn){
if (!(root->color & (1 << turn))) {
return 0;
}
for (int i = 0; i < maxc; i++) {
if (root->children[i] && !search(root->children[i], turn ^ 1)) {
return 1;
}
}
return 0;
}
int n, m;
int main(){
struct node *root = getNode();
cin >> n;
for (int i = 0; i < n; i++)
{
string a;
cin >> a;
insert(root, a, 1);
}
cin >> m;
for (int i = 0; i < m; i++)
{
string a;
cin >> a;
insert(root, a, 2);
}
if(search(root, 0)){
cout << "Nina";
}else{
cout << "Emilija";
}
}
Compilation message (stderr)
| # | 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... | ||||
