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 in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
//#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define arr_all(x, n) (x + 1), (x + 1 + n)
#define vi vector<int>
#define pb push_back
#define len(x) (int)x.size()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 1e6;
vector <int*> bor;
vector <int*> kol;
int dp[N];
void create_new_vertex()
{
bor.pb(NULL);
bor.back() = (int*)calloc(sizeof(int), 26);
kol.pb(NULL);
kol.back() = (int*)calloc(sizeof(int), 2);
}
string cur;
void Add(int nom)
{
int x = 0;
kol[0][nom]++;
for (int i = 0; i < cur.size(); i++)
{
int y = cur[i] - 'a';
if (bor[x][y] == 0) bor[x][y] = len(bor), create_new_vertex();
x = bor[x][y];
kol[x][nom]++;
}
}
int Rec(int x, int par)
{
bool g = 0;
for (int i = 0; i < 26; i++)
if (bor[x][i] != 0 && kol[bor[x][i]][par] > 0) g = g || (!Rec(bor[x][i], par ^ 1));
return g;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
create_new_vertex();
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> cur;
Add(0);
}
int m;
cin >> m;
for (int i = 0; i < m; i++)
{
cin >> cur;
Add(1);
}
cout << (Rec(0, 0) ? "Nina" : "Emilija");
}
Compilation message (stderr)
Main.cpp: In function 'void Add(int)':
Main.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | for (int i = 0; i < cur.size(); i++)
| ~~^~~~~~~~~~~~
# | 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... |