# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
688574 |
2023-01-27T18:18:16 Z |
rieyuw |
Vlak (COCI20_vlak) |
C++17 |
|
107 ms |
67828 KB |
#include <bits/stdc++.h>
using namespace std;
const int mxN = 2e5+1;
vector<vector<array<int,3>>> nxt(mxN, vector<array<int,3>>(26));
bool dfs(int node, int depth)
{
int par = (depth & 1);
bool res = !par;
bool noMove = true;
for (int i = 0; i < 26; ++i)
{
array<int,3>& p = nxt[node][i];
noMove &= (p[0] == 0 || p[2 - par] == 0);
if (p[0] != 0 & p[2-par])
{
bool neigRes = dfs(p[0], depth+1);
if (par)
res |= neigRes;
else
res &= neigRes;
}
}
if (noMove)
res = !par;
return res;
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0);
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:17:18: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
17 | if (p[0] != 0 & p[2-par])
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
67556 KB |
Output is correct |
2 |
Correct |
89 ms |
67536 KB |
Output is correct |
3 |
Correct |
88 ms |
67552 KB |
Output is correct |
4 |
Correct |
88 ms |
67580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
67512 KB |
Output is correct |
2 |
Correct |
94 ms |
67572 KB |
Output is correct |
3 |
Correct |
89 ms |
67624 KB |
Output is correct |
4 |
Correct |
90 ms |
67604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
67608 KB |
Output is correct |
2 |
Correct |
90 ms |
67620 KB |
Output is correct |
3 |
Correct |
89 ms |
67656 KB |
Output is correct |
4 |
Correct |
90 ms |
67596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
67620 KB |
Output is correct |
2 |
Correct |
87 ms |
67560 KB |
Output is correct |
3 |
Correct |
88 ms |
67540 KB |
Output is correct |
4 |
Correct |
88 ms |
67532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
67796 KB |
Output is correct |
2 |
Correct |
96 ms |
67744 KB |
Output is correct |
3 |
Correct |
96 ms |
67768 KB |
Output is correct |
4 |
Correct |
97 ms |
67748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
67764 KB |
Output is correct |
2 |
Correct |
93 ms |
67796 KB |
Output is correct |
3 |
Correct |
95 ms |
67828 KB |
Output is correct |
4 |
Correct |
92 ms |
67812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
67724 KB |
Output is correct |
2 |
Correct |
102 ms |
67784 KB |
Output is correct |
3 |
Correct |
90 ms |
67756 KB |
Output is correct |
4 |
Correct |
92 ms |
67736 KB |
Output is correct |