#include <bits/stdc++.h>
using namespace std;
const int mxN = 2e5+1;
vector<vector<array<int,3>>> nxt(mxN, vector<array<int,3>>(26));
//vector<bool> winning(mxN);
bool dfs(int node, int depth)
{
int par = (depth & 1);
bool res = !par;
bool leave = true;
for (int i = 0; i < 26; ++i)
{
array<int,3>& p = nxt[node][i];
leave &= (p[0] == 0);
if (p[0] != 0 & p[par])
{
if (par)
res |= dfs(p[0], depth+1);
else
res &= dfs(p[0], depth+1);
}
}
if (leave)
return (depth%2);
else
return res;
}
int main()
{
int n; cin >> n;
string s;
int MAXID = 0;
while(n--)
{
cin >> s;
int node = 0;
for (char c : s)
{
array<int,3>& p = nxt[node][c-'a'];
if (p[0] == 0)
p[0] = ++MAXID;
p[1] = 1;
node = p[0];
}
}
int m; cin >> m;
while(m--)
{
cin >> s;
int node = 0;
for (char c : s)
{
array<int,3>& p = nxt[node][c-'a'];
if (p[0] == 0)
p[0] = ++MAXID;
p[2] = 1;
node = p[0];
}
}
cout << (dfs(0, 1) ? "Nina" : "Emilija") << "\n";
}
Compilation message
Main.cpp: In function 'bool dfs(int, int)':
Main.cpp:18:18: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
18 | if (p[0] != 0 & p[par])
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
92 ms |
67604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
90 ms |
67528 KB |
Output is correct |
2 |
Correct |
90 ms |
67572 KB |
Output is correct |
3 |
Correct |
88 ms |
67536 KB |
Output is correct |
4 |
Incorrect |
86 ms |
67560 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
67600 KB |
Output is correct |
2 |
Correct |
85 ms |
67584 KB |
Output is correct |
3 |
Incorrect |
90 ms |
67532 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
85 ms |
67536 KB |
Output is correct |
2 |
Correct |
89 ms |
67532 KB |
Output is correct |
3 |
Correct |
90 ms |
67612 KB |
Output is correct |
4 |
Correct |
87 ms |
67560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
98 ms |
67788 KB |
Output is correct |
2 |
Incorrect |
104 ms |
67784 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
95 ms |
67780 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
99 ms |
67756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |