#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include "bits_stdc++.h"
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define input(x) scanf("%lld", &x);
#define input2(x, y) scanf("%lld%lld", &x, &y);
#define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z);
#define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a);
#define print(x, y) printf("%lld%c", x, y);
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
ll tries[200005][26];
ll ending[200005][2];
ll dp[200005][26];
ll label = 0;
void insert(string word, ll of)
{
ll now = 0;
for (char c: word)
{
if (tries[now][c-'a']==-1) tries[now][c-'a'] = ++label;
now = tries[now][c-'a'];
}
ending[now][of]++;
}
void dfs(ll from, ll of)
{
if (dp[from][of]!=-1) return;
bool can = false;
for (ll i=0; i<26; ++i)
{
if (tries[from][i]==-1) continue;
dfs(tries[from][i], (1-of)%2);
for (ll k=0; k<2; ++k) ending[from][k]+=ending[tries[from][i]][k];
if (ending[tries[from][i]][of]==0) continue;
can = (can || (dp[tries[from][i]][(1-of)%2]==0));
}
dp[from][of] = can;
}
int main()
{
ll n, m;
string word;
input(n);
for (ll i=0; i<200005; ++i) for (ll j=0; j<26; ++j) {tries[i][j] = -1; dp[i][j] = -1;}
for (ll i=0; i<200005; ++i) for (ll j=0; j<2; ++j) ending[i][j] = 0;
for (ll i=0; i<n; ++i)
{
cin >> word;
insert(word, 0);
}
input(m);
for (ll i=0; i<m; ++i)
{
cin >> word;
insert(word, 1);
}
dfs(0, 0);
if (dp[0][0]) cout << "Nina" << endl;
else cout << "Emilija" << endl;
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | #define input(x) scanf("%lld", &x);
| ~~~~~^~~~~~~~~~~~
Main.cpp:64:2: note: in expansion of macro 'input'
64 | input(n);
| ^~~~~
Main.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | #define input(x) scanf("%lld", &x);
| ~~~~~^~~~~~~~~~~~
Main.cpp:72:2: note: in expansion of macro 'input'
72 | input(m);
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
84816 KB |
Output is correct |
2 |
Correct |
13 ms |
84828 KB |
Output is correct |
3 |
Correct |
13 ms |
84828 KB |
Output is correct |
4 |
Correct |
14 ms |
84824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
84920 KB |
Output is correct |
2 |
Correct |
13 ms |
84828 KB |
Output is correct |
3 |
Correct |
12 ms |
84828 KB |
Output is correct |
4 |
Correct |
14 ms |
84884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
84828 KB |
Output is correct |
2 |
Correct |
13 ms |
84824 KB |
Output is correct |
3 |
Correct |
13 ms |
84828 KB |
Output is correct |
4 |
Correct |
13 ms |
84828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
84828 KB |
Output is correct |
2 |
Correct |
12 ms |
84984 KB |
Output is correct |
3 |
Correct |
13 ms |
84828 KB |
Output is correct |
4 |
Correct |
13 ms |
84956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
85084 KB |
Output is correct |
2 |
Correct |
27 ms |
85084 KB |
Output is correct |
3 |
Correct |
29 ms |
85340 KB |
Output is correct |
4 |
Correct |
28 ms |
85084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
85080 KB |
Output is correct |
2 |
Correct |
27 ms |
85084 KB |
Output is correct |
3 |
Correct |
27 ms |
85124 KB |
Output is correct |
4 |
Correct |
26 ms |
85084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
85036 KB |
Output is correct |
2 |
Correct |
26 ms |
85160 KB |
Output is correct |
3 |
Correct |
26 ms |
84952 KB |
Output is correct |
4 |
Correct |
27 ms |
85152 KB |
Output is correct |