# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
938482 | asdasdqwer | Vlak (COCI20_vlak) | C++14 | 1051 ms | 19956 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 let;
map<char, int> ni;
map<char, int> em;
bool emTurn=false, niTurn=false;
};
vector<Node> trie;
void ins(string &s, bool isEm = false) {
int idx=0;
for (auto &x:s) {
if (isEm) {
if (trie[idx].em.find(x) == trie[idx].em.end()) {
if (trie[idx].ni.find(x) == trie[idx].ni.end()) {
Node n1;
n1.let = x;
trie.push_back(n1);
trie[idx].em[x] = (int)trie.size() - 1;
}
else {
trie[idx].em[x] = trie[idx].ni[x];
}
}
idx = trie[idx].em[x];
}
else {
if (trie[idx].ni.find(x) == trie[idx].ni.end()) {
if (trie[idx].em.find(x) == trie[idx].em.end()) {
Node n1;
n1.let = x;
trie.push_back(n1);
trie[idx].ni[x] = (int)trie.size() - 1;
}
else {
trie[idx].ni[x] = trie[idx].em[x];
}
}
idx = trie[idx].ni[x];
}
}
}
void dfs(int idx) {
for (auto [c, i]:trie[idx].ni) {
dfs(i);
if (!trie[i].emTurn) {
trie[idx].niTurn = true;
}
}
for (auto [c, i]:trie[idx].em) {
dfs(i);
if (!trie[i].niTurn) {
trie[idx].emTurn = true;
}
}
}
signed main() {
int n;cin>>n;
Node n1;
trie.push_back(n1);
for (int i=0;i<n;i++) {
string s;cin>>s;
ins(s);
}
int m;cin>>m;
for (int i=0;i<m;i++) {
string s;cin>>s;
ins(s, true);
}
dfs(0);
if (trie[0].niTurn) {
cout<<"Nina\n";
}
else {
cout<<"Emilja\n";
}
}
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... |