This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |