# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1006562 | vjudge1 | Vlak (COCI20_vlak) | C++17 | 21 ms | 20496 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;
string ans[] = {"Emilija", "Nina"};
struct node
{
node *ch[26];
bool f, s;
bool fw, sw;
node()
{
f = fw = s = sw = false;
for(int i = 0; i < 26; i++) ch[i] = NULL;
}
void insert(string &t, bool fir, int i = 0)
{
f |= fir;
s |= (!fir);
if(i == t.size()) return;
int c = t[i] - 'a';
if(ch[c] == NULL)
ch[c] = new node();
ch[c] -> insert(t, fir, i + 1);
}
void compute()
{
bool leaf = true;
for(int i = 0; i < 26; i ++)
if(ch[i] != NULL)
{
leaf = false;
ch[i] -> compute();
fw |= !ch[i]->sw;
sw |= !ch[i]->fw;
}
if(!f) fw = false;
if(!s) sw = false;
if(leaf) fw = sw = false;
}
};
node *root = new node();
int main()
{
int n;
cin >> n;
for(int i = 0; i < n; i ++)
{
string s;
cin >> s;
root -> insert(s, true);
}
cin >> n;
for(int i = 0; i < n; i ++)
{
string s;
cin >> s;
root -> insert(s, false);
}
root -> compute();
cout << ans[root -> fw] << endl;
return 0;
}
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... |