# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
692135 | Tien_Noob | Vlak (COCI20_vlak) | C++17 | 17 ms | 14624 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.
//Make CSP great again
//Vengeance
#include <bits/stdc++.h>
#define TASK "TESTCODE"
using namespace std;
struct Trie
{
struct node
{
int rep, child[26];
node()
{
rep = 0;
memset(child, -1, sizeof(child));
}
};
vector<node> tree;
Trie()
{
tree.emplace_back();
}
void add(string &s, int t)
{
int id = 0;
for (char c : s)
{
int w = c - 'a';
if (tree[id].child[w] == -1)
{
tree[id].child[w] = tree.size();
tree.emplace_back();
}
id = tree[id].child[w];
tree[id].rep |= (1 << t);
}
}
bool DFS(int u, int t)
{
for (int c = 0; c < 26; ++ c)
{
int v = tree[u].child[c];
if (v == -1)
{
continue;
}
if (tree[v].rep == (1 << t))
{
return true;
}
if (tree[v].rep == 3 && !DFS(v, t ^ 1))
{
return true;
}
}
return false;
}
} tree;
void readinput(int t)
{
int n;
cin >> n;
while(n--)
{
string s;
cin >> s;
tree.add(s, t);
}
}
void read()
{
readinput(0);
readinput(1);
}
void solve()
{
cout << (tree.DFS(0, 0) ? "Nina" : "Emilija");
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if (fopen(TASK".INP", "r"))
{
freopen(TASK".INP", "r", stdin);
//freopen(TASK".OUT", "w", stdout);
}
int t = 1;
bool typetest = false;
if (typetest)
{
cin >> t;
}
for (int __ = 1; __ <= t; ++ __)
{
//cout << "Case " << __ << ": ";
read();
solve();
}
}
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... |