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;
int trie[200001][26];
bool var[200001][2];
int las=1;
void ekle(string word,int player){
int pos=0;
for(char c:word){
if(!trie[pos][c-'a']){
trie[pos][c-'a']=las++;
}
pos=trie[pos][c-'a'];
var[pos][player]=1;
}
}
bool dfs(int pos,int sira){
for(int i=0;i<26;i++){
if(!trie[pos][i])continue;
if(!var[trie[pos][i]][sira])continue;
if(dfs(trie[pos][i],sira^1)==sira)return sira;
}
return sira^1;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n;cin>>n;
for(int i=0;i<n;i++){
string s;cin>>s;
ekle(s,0);
}
cin>>n;
for(int i=0;i<n;i++){
string s;cin>>s;
ekle(s,1);
}
if(dfs(0,0))cout<<"Emilija";
else cout<<"Nina";
}
# | 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... |