# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
395456 |
2021-04-28T11:25:56 Z |
MrRobot_28 |
Vlak (COCI20_vlak) |
C++17 |
|
26 ms |
21040 KB |
#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 |
1 |
Correct |
15 ms |
20556 KB |
Output is correct |
2 |
Correct |
13 ms |
20556 KB |
Output is correct |
3 |
Correct |
13 ms |
20648 KB |
Output is correct |
4 |
Correct |
15 ms |
20676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
20588 KB |
Output is correct |
2 |
Correct |
13 ms |
20556 KB |
Output is correct |
3 |
Correct |
13 ms |
20616 KB |
Output is correct |
4 |
Correct |
13 ms |
20556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
20556 KB |
Output is correct |
2 |
Correct |
13 ms |
20556 KB |
Output is correct |
3 |
Correct |
13 ms |
20672 KB |
Output is correct |
4 |
Correct |
13 ms |
20552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
20676 KB |
Output is correct |
2 |
Correct |
13 ms |
20580 KB |
Output is correct |
3 |
Correct |
16 ms |
20636 KB |
Output is correct |
4 |
Correct |
13 ms |
20628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
21040 KB |
Output is correct |
2 |
Correct |
24 ms |
20940 KB |
Output is correct |
3 |
Correct |
23 ms |
20940 KB |
Output is correct |
4 |
Correct |
22 ms |
20944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
20940 KB |
Output is correct |
2 |
Correct |
20 ms |
20940 KB |
Output is correct |
3 |
Correct |
21 ms |
20932 KB |
Output is correct |
4 |
Correct |
21 ms |
20944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
20932 KB |
Output is correct |
2 |
Correct |
22 ms |
21032 KB |
Output is correct |
3 |
Correct |
22 ms |
20920 KB |
Output is correct |
4 |
Correct |
26 ms |
20936 KB |
Output is correct |