#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5+10;
vector<vector<int>> nxt(mxN, vector<int>(26));
vector<int> color(mxN);
bool dfs(int node, int depth)
{
int par = (depth & 1);
bool res = !par;
for (int i = 0; i < 26 && res != par; ++i)
{
int neig = nxt[node][i];
if (neig != 0 && ((color[neig] >> par) & 1))
{
bool neigRes = dfs(neig, depth+1);
if (par)
res |= neigRes;
else
res &= neigRes;
}
}
return res;
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0);
int n; cin >> n;
string s;
int MAXID = 0;
color[0] = 3;
while(n--)
{
cin >> s;
int node = 0;
for (char c : s)
{
if (nxt[node][c-'a'] == 0)
nxt[node][c-'a'] = ++MAXID;
node = nxt[node][c-'a'];
color[node] |= 2;
}
}
int m; cin >> m;
while(m--)
{
cin >> s;
int node = 0;
for (char c : s)
{
if (nxt[node][c-'a'] == 0)
nxt[node][c-'a'] = ++MAXID;
node = nxt[node][c-'a'];
color[node] |= 1;
}
}
cout << (dfs(0, 1) ? "Nina" : "Emilija") << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
13992 KB |
Output is correct |
2 |
Correct |
9 ms |
13932 KB |
Output is correct |
3 |
Correct |
9 ms |
14016 KB |
Output is correct |
4 |
Correct |
9 ms |
13952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14040 KB |
Output is correct |
2 |
Correct |
10 ms |
13908 KB |
Output is correct |
3 |
Correct |
9 ms |
13908 KB |
Output is correct |
4 |
Correct |
10 ms |
13908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
13908 KB |
Output is correct |
2 |
Correct |
9 ms |
13908 KB |
Output is correct |
3 |
Correct |
9 ms |
13908 KB |
Output is correct |
4 |
Correct |
9 ms |
13908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
13908 KB |
Output is correct |
2 |
Correct |
9 ms |
14012 KB |
Output is correct |
3 |
Correct |
10 ms |
13908 KB |
Output is correct |
4 |
Correct |
9 ms |
14008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
14180 KB |
Output is correct |
2 |
Correct |
14 ms |
14172 KB |
Output is correct |
3 |
Correct |
13 ms |
14184 KB |
Output is correct |
4 |
Correct |
16 ms |
14244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
14180 KB |
Output is correct |
2 |
Correct |
12 ms |
14180 KB |
Output is correct |
3 |
Correct |
12 ms |
14236 KB |
Output is correct |
4 |
Correct |
12 ms |
14164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
14140 KB |
Output is correct |
2 |
Correct |
12 ms |
14164 KB |
Output is correct |
3 |
Correct |
13 ms |
14164 KB |
Output is correct |
4 |
Correct |
13 ms |
14228 KB |
Output is correct |