# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
727800 | madtuber | Vlak (COCI20_vlak) | C++14 | 14 ms | 10392 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>
#define all(x) begin(x),end(x)
#define fir first
#define sec second
#define sz(x) x.size()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;
using pdb = pair<double,double>;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using ull = unsigned long long;
const double EPS = (1e-6);
void setio(string s){
freopen((s + ".in").c_str(),"r",stdin);
freopen((s + ".out").c_str(),"w",stdout);
}
struct Trie{
map<char, Trie> c;
pi own{0,0};
bool mark = false;
void insert(int cur, string& s, int pos){
if (cur % 2) own.sec = 1;
else own.fir = 1;
if (pos != sz(s)) c[s[pos]].insert(cur, s, pos+1);
else mark = true;
}
//if cur % 2, a's turn, else b's turn
int dfs(int cur){
if (cur % 2){
int res = 0;
for(auto& j : c){
if (j.sec.own.sec){
res = max(res, j.sec.dfs(cur+1));
}
}
return res;
}else{
int res = 1;
for(auto& j : c){
if (j.sec.own.fir){
res = min(res, j.sec.dfs(cur+1));
}
}
return res;
}
}
};
void solve(){
int n;
cin >> n;
Trie tr;
for(int i{}; i < n; i++){
string s;
cin >> s;
tr.insert(0, s, 0);
}
int m;
cin >> m;
for(int i{}; i < m; i++){
string s;
cin >> s;
tr.insert(1, s, 0);
}
cout << (tr.dfs(0) == 0 ? "Nina" : "Emilija");
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
while(t--){
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... |