#include <bits/stdc++.h>
//LIFE IS NOT A PROBLEM TO BE SOLVED
#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define all(s) s.begin(), s.end()
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
using namespace std;
typedef long long int ll;
typedef pair<ll, int> ii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int MAXN = 200200;
const int MAXL = 40;
int sig[MAXN][MAXL];
int term[MAXN];
int cnt = 1;
int val(char c) {
return c - 'a';
}
void add(string& s, int id) {
int tam = s.size(), x = 0;
term[x] |= (1 << id);
for (auto c : s) {
int vc = val(c);
if (!sig[x][vc]) sig[x][vc] = cnt++;
x = sig[x][vc];
term[x] |= (1 << id);
}
}
int pd[MAXN][2];
int solve(int x, int op) {
int& ret = pd[x][op];
if (ret != -1) return ret;
if (!((1 << op) & term[x])) return ret = 0;
ret = 0;
for (char c = 'a'; c <= 'z'; c++) {
int vc = val(c);
if (!sig[x][vc]) continue;
int go = solve(sig[x][vc], op ^ 1);
ret |= (go == 0);
}
return ret;
}
int main() {
int n, m;
string s;
scanf("%d", &n);
rep(i, 0, n) {
cin >> s;
add(s, 0);
}
scanf("%d", &m);
rep(i, 0, m) {
cin >> s;
add(s, 1);
}
memset(pd, -1, sizeof pd);
int ans = solve(0, 0);
ans ? puts("Nina") : puts("Emilija");
return 0;
}
Compilation message
Main.cpp: In function 'void add(std::string&, int)':
Main.cpp:35:9: warning: unused variable 'tam' [-Wunused-variable]
35 | int tam = s.size(), x = 0;
| ^~~
Main.cpp: In function 'int main()':
Main.cpp:67:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
67 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
Main.cpp:73:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
73 | scanf("%d", &m);
| ~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1996 KB |
Output is correct |
2 |
Correct |
1 ms |
1996 KB |
Output is correct |
3 |
Correct |
1 ms |
1996 KB |
Output is correct |
4 |
Correct |
1 ms |
1960 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1996 KB |
Output is correct |
2 |
Correct |
1 ms |
1960 KB |
Output is correct |
3 |
Correct |
1 ms |
1996 KB |
Output is correct |
4 |
Correct |
1 ms |
1996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1996 KB |
Output is correct |
2 |
Correct |
1 ms |
1996 KB |
Output is correct |
3 |
Correct |
1 ms |
1996 KB |
Output is correct |
4 |
Correct |
1 ms |
2000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1996 KB |
Output is correct |
2 |
Correct |
1 ms |
1996 KB |
Output is correct |
3 |
Correct |
1 ms |
1996 KB |
Output is correct |
4 |
Correct |
1 ms |
1996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
15656 KB |
Output is correct |
2 |
Correct |
17 ms |
14808 KB |
Output is correct |
3 |
Correct |
17 ms |
14016 KB |
Output is correct |
4 |
Correct |
17 ms |
15352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
15948 KB |
Output is correct |
2 |
Correct |
17 ms |
16572 KB |
Output is correct |
3 |
Correct |
20 ms |
15384 KB |
Output is correct |
4 |
Correct |
17 ms |
15636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
15136 KB |
Output is correct |
2 |
Correct |
16 ms |
14812 KB |
Output is correct |
3 |
Correct |
21 ms |
15152 KB |
Output is correct |
4 |
Correct |
17 ms |
16060 KB |
Output is correct |