# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
688578 |
2023-01-27T18:27:52 Z |
rieyuw |
Vlak (COCI20_vlak) |
C++17 |
|
56 ms |
33996 KB |
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5+10;
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;
for (int i = 0; i < 26 && res != par; ++i)
{
array<int,3>& p = nxt[node][i];
if (p[0] != 0 & p[2-par])
{
bool neigRes = dfs(p[0], 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;
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:15:18: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
15 | if (p[0] != 0 & p[2-par])
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
33996 KB |
Output is correct |
2 |
Correct |
44 ms |
33852 KB |
Output is correct |
3 |
Correct |
45 ms |
33868 KB |
Output is correct |
4 |
Correct |
43 ms |
33904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
33868 KB |
Output is correct |
2 |
Correct |
47 ms |
33952 KB |
Output is correct |
3 |
Correct |
47 ms |
33964 KB |
Output is correct |
4 |
Correct |
51 ms |
33868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
33916 KB |
Output is correct |
2 |
Correct |
48 ms |
33864 KB |
Output is correct |
3 |
Correct |
48 ms |
33856 KB |
Output is correct |
4 |
Correct |
44 ms |
33848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
33868 KB |
Output is correct |
2 |
Correct |
44 ms |
33876 KB |
Output is correct |
3 |
Correct |
46 ms |
33904 KB |
Output is correct |
4 |
Correct |
49 ms |
33928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
33868 KB |
Output is correct |
2 |
Correct |
48 ms |
33880 KB |
Output is correct |
3 |
Correct |
48 ms |
33856 KB |
Output is correct |
4 |
Correct |
50 ms |
33920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
33936 KB |
Output is correct |
2 |
Correct |
48 ms |
33868 KB |
Output is correct |
3 |
Correct |
51 ms |
33920 KB |
Output is correct |
4 |
Correct |
47 ms |
33940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
33916 KB |
Output is correct |
2 |
Correct |
48 ms |
33900 KB |
Output is correct |
3 |
Correct |
48 ms |
33868 KB |
Output is correct |
4 |
Correct |
56 ms |
33844 KB |
Output is correct |