# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1015908 | vjudge1 | Vlak (COCI20_vlak) | C++17 | 14 ms | 15680 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.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define _GLIBCXX_FILESYSTEM
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct Trie{
struct node{
int nxt[26];
node(){
memset(nxt,-1,sizeof(nxt));
}
};
vector<node> trie;
Trie(){
trie.emplace_back();
}
void insert(string &s){
int cur = 0;
for(int i = 0; i < s.size(); i++){
if(trie[cur].nxt[s[i]-'a'] == -1){
trie[cur].nxt[s[i]-'a'] = trie.size();
trie.push_back(node());
}
cur = trie[cur].nxt[s[i]-'a'];
}
}
};
Trie nina,emil;
int dfs(int i,int j,int cur){
for(int k = 0; k < 26; k++){
if(cur){
if(emil.trie[j].nxt[k] != -1 and nina.trie[i].nxt[k] == -1) return 1;
}
else{
if(nina.trie[i].nxt[k] != -1 and emil.trie[j].nxt[k] == -1) return 1;
}
}
vector<bool> mex(27,0);
for(int k = 0; k < 26; k++){
if(emil.trie[j].nxt[k] != -1 and nina.trie[i].nxt[k] != -1){
int now = dfs(nina.trie[i].nxt[k],emil.trie[j].nxt[k],cur^1);
if(now < 27) mex[now] = 1;
}
}
for(int k = 0; k < 27; k++){
if(!mex[k]) return k;
}
}
void solve() {
int n;
cin >> n;
for(int i = 0; i < n; i++){
string s;
cin >> s;
nina.insert(s);
}
int m;
cin >> m;
for(int i = 0; i < m; i++){
string s;
cin >> s;
emil.insert(s);
}
if(dfs(0,0,0)) cout << "Nina\n";
else cout << "Emilija\n";
return;
}
int32_t main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
int tc = 1;
// cin >> tc;
for(int kase = 1; kase <= tc; kase++) {
//cout << "Case " << kase << ": ";
solve();
}
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... |