# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1121206 | hahahoang132 | Vlak (COCI20_vlak) | C++17 | 27 ms | 24656 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;
using ll = long long;
const ll N = 1e7;
const ll base = 10007;
const ll inf = LLONG_MAX/4;
const ll mod = 1e9 + 7;
#define bit(x,y) ((x >> y) & 1)
struct node
{
node* c[30];
ll haha[2];
node()
{
haha[0] = haha[1] = 0;
for(ll i = 0;i < 26;i++) c[i] = NULL;
}
};
struct trie
{
node r;
void add(string s, ll t)
{
ll i = 0;
node *cur = &r;
while(i < s.size())
{
ll k = s[i] - 'a';
if(!cur->c[k])
{
cur->c[k] = new node();
}
cur = cur->c[k];
cur->haha[t] = 1;
i++;
}
}
ll cal(node *cur, ll e)
{
ll ans = 0;
for(ll i = 0;i < 26;i++)
{
if(cur->c[i] && cur->c[i]->haha[e])
{
if(!cal(cur->c[i],1 - e)) ans = 1;
}
}
return ans;
}
};
trie f;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n,m;
cin >> n;
ll i,j;
for(i = 1;i <= n;i++)
{
string s;
cin >> s;
f.add(s,0);
}
cin >> m;
for(i = 1;i <= m;i++)
{
string s;
cin >> s;
f.add(s,1);
}
if(f.cal(&f.r,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... |