#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
constexpr bool pattern[6] = {0, 0, 1, 1, 0, 1};
vector<int> Mark(int n, int m, int a, int b, vector<int> u, vector<int> v)
{
vector<vector<int>> g(n);
for (size_t i = 0; i < m; ++i)
g[u[i]].push_back(v[i]), g[v[i]].push_back(u[i]);
queue<int> q;
q.push(0);
vector<int> d(n, -1), pattern_index(n, -1);
vector<bool> color(n, 0);
d[0] = pattern_index[0] = 0;
while (!q.empty())
{
int const x = q.front();
q.pop();
for (auto const &y : g[x])
if (d[y] == -1)
{
d[y] = d[x] + 1;
q.push(y);
if (g[y].size() <= 2)
{
pattern_index[y] = (pattern_index[x] + 1) % 6;
color[y] = color[x];
}
else
{
pattern_index[y] = 0;
color[y] = !color[x];
}
}
}
vector<int> ans(m);
if (a >= 3)
{
for (size_t i = 0; i < m; ++i)
ans[i] = min(d[u[i]], d[v[i]]) % 3;
}
else
{
for (size_t i = 0; i < m; ++i)
{
if (d[u[i]] > d[v[i]])
swap(u[i], v[i]);
ans[i] = pattern[pattern_index[u[i]]] ^ color[u[i]];
}
}
return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
bool is_tree, initialized;
vector<int> colors;
constexpr bool pattern[6] = {0, 0, 1, 1, 0, 1};
void Init(int a, int b)
{
colors.clear();
is_tree = a == 2;
initialized = 0;
}
int Move(vector<int> y)
{
if (!is_tree)
{
if (!colors.empty())
y[colors.back()]++;
if ((bool)y[0] + (bool)y[1] + (bool)y[2] == 1)
{
if (y[0])
{
colors.push_back(0);
return 0;
}
else if (y[1])
{
colors.push_back(1);
return 1;
}
else
{
colors.push_back(2);
return 2;
}
}
if (!y[0])
{
colors.push_back(1);
return 1;
}
else if (!y[1])
{
colors.push_back(2);
return 2;
}
else
{
colors.push_back(0);
return 0;
}
}
else
{
if (colors.empty() && y[0] + y[1] >= 3)
{
initialized = 1;
if (y[0] == 1)
{
colors.push_back(0);
return 0;
}
else
{
colors.push_back(1);
return 1;
}
}
if (!initialized)
{
if (y[0] + y[1] >= 2)
{
initialized = 1;
if (!y[colors.back()])
return -1;
else
return !colors.back();
}
else
{
if (colors.size() == 4)
{
initialized = 1;
for (size_t i = 0; i < 6; ++i) /* pattern */
{
bool correct = 1;
for (size_t j = 0; j < 4; ++j)
correct &= colors[j] == pattern[(i + j) % 6];
if (correct)
return -1;
}
for (size_t i = 0; i < 6; ++i) /* inverted pattern */
{
bool correct = 1;
for (size_t j = 0; j < 4; ++j)
correct &= colors[j] == !pattern[(i + j) % 6];
if (correct)
return -1;
}
return !colors.back();
}
if (colors.empty())
{
if (y[0] == 2)
colors.push_back(0);
else
colors.push_back(1);
}
if (y[0])
{
colors.push_back(y[0]);
return 0;
}
else
{
colors.push_back(y[1]);
return 1;
}
}
}
else
{
if (y[0] + y[1] >= 2)
{
colors.push_back(!colors.back());
return !colors.back();
}
colors.push_back(y[1]);
return y[1];
}
}
}
Compilation message
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:10:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
10 | for (size_t i = 0; i < m; ++i)
| ~~^~~
Anthony.cpp:44:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
44 | for (size_t i = 0; i < m; ++i)
| ~~^~~
Anthony.cpp:49:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
49 | for (size_t i = 0; i < m; ++i)
| ~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
15080 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
31 ms |
14308 KB |
Output is correct |
4 |
Correct |
52 ms |
16268 KB |
Output is correct |
5 |
Correct |
44 ms |
16232 KB |
Output is correct |
6 |
Correct |
36 ms |
14760 KB |
Output is correct |
7 |
Correct |
36 ms |
14904 KB |
Output is correct |
8 |
Correct |
44 ms |
15528 KB |
Output is correct |
9 |
Correct |
43 ms |
15624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
15080 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
31 ms |
14308 KB |
Output is correct |
4 |
Correct |
52 ms |
16268 KB |
Output is correct |
5 |
Correct |
44 ms |
16232 KB |
Output is correct |
6 |
Correct |
36 ms |
14760 KB |
Output is correct |
7 |
Correct |
36 ms |
14904 KB |
Output is correct |
8 |
Correct |
44 ms |
15528 KB |
Output is correct |
9 |
Correct |
43 ms |
15624 KB |
Output is correct |
10 |
Correct |
32 ms |
12884 KB |
Output is correct |
11 |
Correct |
38 ms |
12936 KB |
Output is correct |
12 |
Correct |
31 ms |
12856 KB |
Output is correct |
13 |
Correct |
34 ms |
12824 KB |
Output is correct |
14 |
Correct |
32 ms |
13212 KB |
Output is correct |
15 |
Correct |
36 ms |
13556 KB |
Output is correct |
16 |
Correct |
39 ms |
15776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
12592 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
28 ms |
12272 KB |
Output is correct |
4 |
Correct |
41 ms |
14060 KB |
Output is correct |
5 |
Correct |
45 ms |
14088 KB |
Output is correct |
6 |
Correct |
33 ms |
12672 KB |
Output is correct |
7 |
Correct |
34 ms |
12668 KB |
Output is correct |
8 |
Correct |
42 ms |
13280 KB |
Output is correct |
9 |
Correct |
46 ms |
13288 KB |
Output is correct |
10 |
Correct |
36 ms |
13164 KB |
Output is correct |
11 |
Correct |
36 ms |
13164 KB |
Output is correct |
12 |
Correct |
40 ms |
12968 KB |
Output is correct |
13 |
Correct |
38 ms |
13088 KB |
Output is correct |
14 |
Correct |
40 ms |
13324 KB |
Output is correct |
15 |
Correct |
38 ms |
13332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
12592 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
28 ms |
12272 KB |
Output is correct |
4 |
Correct |
41 ms |
14060 KB |
Output is correct |
5 |
Correct |
45 ms |
14088 KB |
Output is correct |
6 |
Correct |
33 ms |
12672 KB |
Output is correct |
7 |
Correct |
34 ms |
12668 KB |
Output is correct |
8 |
Correct |
42 ms |
13280 KB |
Output is correct |
9 |
Correct |
46 ms |
13288 KB |
Output is correct |
10 |
Correct |
36 ms |
13164 KB |
Output is correct |
11 |
Correct |
36 ms |
13164 KB |
Output is correct |
12 |
Correct |
40 ms |
12968 KB |
Output is correct |
13 |
Correct |
38 ms |
13088 KB |
Output is correct |
14 |
Correct |
40 ms |
13324 KB |
Output is correct |
15 |
Correct |
38 ms |
13332 KB |
Output is correct |
16 |
Correct |
31 ms |
11100 KB |
Output is correct |
17 |
Correct |
30 ms |
11056 KB |
Output is correct |
18 |
Correct |
31 ms |
10968 KB |
Output is correct |
19 |
Correct |
33 ms |
11024 KB |
Output is correct |
20 |
Correct |
38 ms |
11612 KB |
Output is correct |
21 |
Correct |
34 ms |
11388 KB |
Output is correct |
22 |
Correct |
37 ms |
13468 KB |
Output is correct |
23 |
Correct |
31 ms |
11124 KB |
Output is correct |
24 |
Correct |
32 ms |
11124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1160 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
10656 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
18900 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |