# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377831 | kshitij_sodani | Vlak (COCI20_vlak) | C++14 | 20 ms | 10860 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("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
int n,m;
int pre[200001][26];
int val[200001][2];
int dp[200001];
int co=0;
void insert(string s,int ii){
int cur=0;
for(int i=0;i<s.size();i++){
if(pre[cur][s[i]-'a']==0){
co++;
pre[cur][s[i]-'a']=co;
}
cur=pre[cur][s[i]-'a'];
val[cur][ii]++;
}
}
void dfs(int no,int lev=0){
if(lev%2==0){
dp[no]=0;
for(int j=0;j<26;j++){
if(pre[no][j]>0){
//cout<<no<<":"<<pre[no][j]<<":"<<j<<endl;
dfs(pre[no][j],lev+1);
if(val[pre[no][j]][0]>0){
dp[no]|=(1-dp[pre[no][j]]);
}
}
}
}
else{
dp[no]=0;
for(int j=0;j<26;j++){
if(pre[no][j]>0){
//cout<<no<<":"<<pre[no][j]<<":"<<j<<endl;
dfs(pre[no][j],lev+1);
if(val[pre[no][j]][1]>0){
dp[no]|=(1-dp[pre[no][j]]);
}
}
}
}
// cout<<no<<",,"<<dp[no]<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for(int i=0;i<n;i++){
string s;
cin>>s;
insert(s,0);
}
cin>>m;
for(int i=0;i<m;i++){
string s;
cin>>s;
insert(s,1);
}
dfs(0);
if(dp[0]){
cout<<"Nina"<<endl;
}
else{
cout<<"Emilija"<<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... |