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;
#define ll long long
int const N=2e5+5;
int const mod=1e9+7;
int nxt[N][26];
bool st1[N],st2[N];
bool is_pre[N][2],win[N][2];
int cnt=1;
void dfs(int node){
for (int i = 0; i < 26; ++i)
{
if(nxt[node][i]==0)
continue;
int nt=nxt[node][i];
dfs(nt);
win[node][0] |= is_pre[nt][0] && (!win[nt][1]);
win[node][1] |= is_pre[nt][1] && (!win[nt][0]);
}
}
int main(){
for (int p = 0; p < 2; ++p)
{
int n;
cin>>n;
for (int i = 0; i < n; ++i)
{
string a;
cin>>a;
int cur=0;
for(char c:a){
if(nxt[cur][c-'a']==0)
nxt[cur][c-'a']=cnt++;
is_pre[cur][p]=1;
cur=nxt[cur][c-'a'];
}
is_pre[cur][p]=1;
}
}
dfs(0);
if(win[0][0])
cout<<"Nina"<<endl;
else
cout<<"Emilija"<<endl;
return 0;
}
# | 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... |