| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 703579 | PoonYaPat | Vlak (COCI20_vlak) | C++14 | 20 ms | 21880 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>
using namespace std;
struct node {
char c;
int depth;
bool k1,k2,win,endword;
node *child[26];
};
struct node *getnode(char c, int depth) {
struct node *pnode=new node;
pnode->c=c;
pnode->depth=depth;
pnode->k1=false;
pnode->k2=false;
pnode->win=false;
pnode->endword=false;
for (int i=0; i<26; ++i) pnode->child[i]=NULL;
return pnode;
};
//Nina
void add1(string s, node *pnode) {
for (int i=0; i<s.size(); ++i) {
int idx=s[i]-'a';
if (!pnode->child[idx]) pnode->child[idx]=getnode(s[i],pnode->depth+1);
pnode->endword=false;
pnode=pnode->child[idx];
pnode->k1=true;
}
pnode->endword=true;
}
//Emilia
void add2(string s, node *pnode) {
for (int i=0; i<s.size(); ++i) {
int idx=s[i]-'a';
if (!pnode->child[idx]) pnode->child[idx]=getnode(s[i],pnode->depth+1);
pnode->endword=false;
pnode=pnode->child[idx];
pnode->k2=true;
}
pnode->endword=true;
}
bool dfs(node *pnode) {
//game end
if (pnode->depth%2==0 && !pnode->k2) return true;
if (pnode->depth%2==1 && !pnode->k1) return false;
if (pnode->endword) {
if (pnode->depth%2==1) return true;
else return false;
}
//game continue
if (pnode->depth%2==0) {
bool win=false;
for (int i=0; i<26; ++i) {
if (pnode->child[i]) win|=dfs(pnode->child[i]);
}
return win;
} else {
bool win=true;
for (int i=0; i<26; ++i) {
if (pnode->child[i]) win&=dfs(pnode->child[i]);
}
return win;
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n; string s;
struct node *trie = getnode('*',0);
trie->k2=true;
cin>>n;
while (n--) cin>>s, add1(s,trie);
cin>>n;
while (n--) cin>>s, add2(s,trie);
if (dfs(trie)) 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... | ||||
