#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define mxe(v) *max_element(v.begin(), v.end())
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend()
#define F first
#define S second
#define pi pair<ll,ll>
#define assem ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
using namespace std;
const int N=400200;
const double PI=3.1415926535897932384626433;
const double eps = 1e-9;
string getString()
{
char c[(int)2e6];
//scanf(" %c",&a[i]);
scanf("%s", c);
return c;
//string x = getString();
}
///printf("%d\n",);
///scanf("%d",&);
///cout.precision(10);
///puts("")string
int n,m;
vector<string> v;
struct trie
{
trie* child[26];
trie()
{
memset(child,0,sizeof child);
}
void add(int i,int j)
{
if(j==v[i].size())return;
int to=v[i][j]-'a';
if(child[to]==0)child[to]=new trie();
child[to]->add(i,j+1);
}
};
bool dp(trie* a1,trie* a2,bool g)
{
bool f=0;
if(g)
{
for(char i='a'; i<='z'; i++)
{
if(a1->child[i-'a']!=0&&a2->child[i-'a']==0)
{
f=1;
}
else if(a1->child[i-'a']!=0&&a2->child[i-'a']!=0)
{
f=f||!(dp(a1->child[i-'a'],a2->child[i-'a'],!g));
}
}
}
else
{
for(char i='a'; i<='z'; i++)
{
if(a2->child[i-'a']!=0&&a1->child[i-'a']==0)
{
f=1;
}
else if(a2->child[i-'a']!=0&&a1->child[i-'a']!=0)
{
f=f||!(dp(a1->child[i-'a'],a2->child[i-'a'],!g));
}
}
}
return f;
}
int main()
{
cin>>n;
trie* root1=new trie();
for(int i=0; i<n; i++)
{
string q;
cin>>q;
v.push_back(q);
root1->add(i,0);
}
v.clear();
trie* root2=new trie();
cin>>m;
for(int i=0; i<m; i++)
{
string q;
cin>>q;
v.push_back(q);
root2->add(i,0);
}
if(dp(root1,root2,1))
{
cout<<"Nina"<<endl;
}
else
{
cout<<"Emilija"<<endl;
}
}
Compilation message
Main.cpp: In member function 'void trie::add(int, int)':
Main.cpp:41:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | if(j==v[i].size())return;
| ~^~~~~~~~~~~~~
Main.cpp: In function 'std::string getString()':
Main.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | scanf("%s", c);
| ~~~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
560 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
552 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
496 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
556 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
21448 KB |
Output is correct |
2 |
Correct |
19 ms |
20176 KB |
Output is correct |
3 |
Correct |
22 ms |
19084 KB |
Output is correct |
4 |
Correct |
20 ms |
20948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
21688 KB |
Output is correct |
2 |
Correct |
20 ms |
22720 KB |
Output is correct |
3 |
Correct |
27 ms |
20816 KB |
Output is correct |
4 |
Correct |
19 ms |
21164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
20600 KB |
Output is correct |
2 |
Correct |
20 ms |
20152 KB |
Output is correct |
3 |
Correct |
19 ms |
20552 KB |
Output is correct |
4 |
Correct |
20 ms |
21904 KB |
Output is correct |