#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define sz(a) (int)a.size()
#define ll long long
#define ld long double
const int N = 2e5 + 100;
int dp[N][2];
bool go_to[N][2];
int g[N][26];
int it = 1;
string s;
void go_to1(int st, int i)
{
go_to[st][0] = 1;
if(i == sz(s))
{
return;
}
if(g[st][s[i] - 'a'] == -1)
{
g[st][s[i] - 'a'] = it;
it++;
}
go_to1(g[st][s[i] - 'a'], i + 1);
}
void go_to2(int st, int i)
{
go_to[st][1] = 1;
if(i == sz(s))
{
return;
}
if(g[st][s[i] - 'a'] == -1)
{
g[st][s[i] - 'a'] = it;
it++;
}
go_to2(g[st][s[i] - 'a'], i + 1);
}
int dfs(int i, int t)
{
for(int to = 0; to < 26; to++)
{
if(g[i][to] == -1)
{
continue;
}
if(go_to[g[i][to]][t] && dfs(g[i][to], 1 - t) == t)
{
return t;
}
}
return 1 - t;
}
signed main()
{
//ifstream cin("286.txt");
// ios_base::sync_with_stdio(0);
// cin.tie(0);
//cout.tie(0);
for(int i = 0;i < N; i++)
{
fill(g[i], g[i] + 26, -1);
}
int n;
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> s;
go_to1(0, 0);
}
int m;
cin >> m;
for(int i = 0; i < m; i++)
{
cin >> s;
go_to2(0, 0);
}
//cout << "A";
if(dfs(0, 0) == 0)
{
cout << "Nina";
}
else
{
cout << "Emilija";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
20556 KB |
Output is correct |
2 |
Correct |
14 ms |
20556 KB |
Output is correct |
3 |
Correct |
13 ms |
20596 KB |
Output is correct |
4 |
Correct |
13 ms |
20560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
20556 KB |
Output is correct |
2 |
Correct |
14 ms |
20684 KB |
Output is correct |
3 |
Correct |
13 ms |
20556 KB |
Output is correct |
4 |
Correct |
14 ms |
20568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
20556 KB |
Output is correct |
2 |
Correct |
13 ms |
20624 KB |
Output is correct |
3 |
Correct |
13 ms |
20608 KB |
Output is correct |
4 |
Correct |
13 ms |
20672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
20556 KB |
Output is correct |
2 |
Correct |
13 ms |
20652 KB |
Output is correct |
3 |
Correct |
13 ms |
20584 KB |
Output is correct |
4 |
Correct |
13 ms |
20556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
20812 KB |
Output is correct |
2 |
Correct |
22 ms |
20816 KB |
Output is correct |
3 |
Correct |
22 ms |
20760 KB |
Output is correct |
4 |
Correct |
22 ms |
20836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
20804 KB |
Output is correct |
2 |
Correct |
25 ms |
20792 KB |
Output is correct |
3 |
Correct |
24 ms |
20788 KB |
Output is correct |
4 |
Correct |
21 ms |
20820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
20796 KB |
Output is correct |
2 |
Correct |
21 ms |
20796 KB |
Output is correct |
3 |
Correct |
21 ms |
20820 KB |
Output is correct |
4 |
Correct |
22 ms |
20768 KB |
Output is correct |