#include "Anthony.h"
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
namespace {
int label[6]{1, 1, 0, 1, 0, 0};
vector<pair<int, int>> graph[20000];
vector<int> X;
bool visited[20000];
void bfs() {
queue<tuple<int, int, int>> q;
q.push({0, 0, 0});
visited[0] = true;
while (q.size()) {
int curr, depth, par;
tie(curr, depth, par) = q.front();
q.pop();
if (graph[curr].size() == 2) {
for (pair<int, int> i : graph[curr])
if (!visited[i.first]) {
visited[i.first] = true;
X[i.second] = label[depth];
q.push({i.first, (depth + 1) % 6, label[depth]});
}
} else {
for (pair<int, int> i : graph[curr])
if (!visited[i.first]) {
visited[i.first] = true;
X[i.second] = 1 - par;
q.push({i.first, (par == 1 ? 5 : 1), 1 - par});
}
}
}
}
} // namespace
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
X.resize(M);
FOR(i, 0, M) {
graph[U[i]].push_back({V[i], i});
graph[V[i]].push_back({U[i], i});
}
bfs();
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
namespace {
int A, B, last_visited, ans;
bool going_up, init;
deque<int> seq, target = {0, 0, 1, 1, 0, 1};
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
going_up = false;
init = true;
last_visited = ans = -2;
}
int Move(vector<int> y) {
int deg = accumulate(y.begin(), y.end(), 0), uniq = 0;
for (int i : y)
if (i) uniq++;
if (going_up || (init && deg == 1)) {
going_up = true;
if (uniq == 1) {
FOR(i, 0, 2) if (y[i]) ans = i;
} else {
if (ans == -1)
y[last_visited]++;
else
y[ans]++;
FOR(i, 0, 2) if (y[i] == 1) ans = i;
if (ans == last_visited) ans = -1;
}
} else {
if (init) {
if (deg == 2) {
FOR(i, 0, 2) if (y[i]) ans = i;
seq.push_back(ans);
B -= 2;
} else {
FOR(i, 0, 2) if (y[i] == 1) ans = i;
going_up = true;
}
} else {
if (deg == 1) {
if (!B) {
while (seq[0] || seq[1]) {
seq.push_back(seq.front());
seq.pop_front();
}
going_up = true;
if (seq == target) {
last_visited = ans;
return ans = -1;
} else {
FOR(i, 0, 2) if (y[i]) ans = i;
}
} else {
FOR(i, 0, 2) if (y[i]) ans = i;
seq.push_back(ans);
B -= 2;
}
} else {
if (ans == -1)
y[last_visited]++;
else
y[ans]++;
FOR(i, 0, 2) if (y[i] == 1) ans = i;
if (ans == last_visited) ans = -1;
going_up = true;
}
}
}
init = false;
return last_visited = ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
15268 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
15268 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
13008 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
49 ms |
12916 KB |
Output is correct |
4 |
Correct |
66 ms |
14168 KB |
Output is correct |
5 |
Incorrect |
60 ms |
14068 KB |
Wrong Answer [6] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
13008 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
49 ms |
12916 KB |
Output is correct |
4 |
Correct |
66 ms |
14168 KB |
Output is correct |
5 |
Incorrect |
60 ms |
14068 KB |
Wrong Answer [6] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1792 KB |
Output is correct |
2 |
Correct |
10 ms |
1536 KB |
Output is correct |
3 |
Correct |
11 ms |
1792 KB |
Output is correct |
4 |
Correct |
10 ms |
1548 KB |
Output is correct |
5 |
Correct |
11 ms |
1548 KB |
Output is correct |
6 |
Correct |
10 ms |
1536 KB |
Output is correct |
7 |
Correct |
11 ms |
1888 KB |
Output is correct |
8 |
Correct |
11 ms |
1792 KB |
Output is correct |
9 |
Correct |
10 ms |
1792 KB |
Output is correct |
10 |
Correct |
10 ms |
1536 KB |
Output is correct |
11 |
Correct |
10 ms |
1796 KB |
Output is correct |
12 |
Correct |
11 ms |
1536 KB |
Output is correct |
13 |
Correct |
10 ms |
1536 KB |
Output is correct |
14 |
Correct |
10 ms |
1548 KB |
Output is correct |
15 |
Correct |
10 ms |
1536 KB |
Output is correct |
16 |
Correct |
10 ms |
1548 KB |
Output is correct |
17 |
Correct |
10 ms |
1548 KB |
Output is correct |
18 |
Correct |
12 ms |
1536 KB |
Output is correct |
19 |
Correct |
10 ms |
1792 KB |
Output is correct |
20 |
Correct |
11 ms |
1744 KB |
Output is correct |
21 |
Correct |
11 ms |
1536 KB |
Output is correct |
22 |
Correct |
10 ms |
1536 KB |
Output is correct |
23 |
Correct |
10 ms |
1536 KB |
Output is correct |
24 |
Correct |
10 ms |
1792 KB |
Output is correct |
25 |
Correct |
10 ms |
1536 KB |
Output is correct |
26 |
Correct |
11 ms |
1536 KB |
Output is correct |
27 |
Correct |
10 ms |
1548 KB |
Output is correct |
28 |
Correct |
11 ms |
1792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
11264 KB |
Output is correct |
2 |
Correct |
62 ms |
11660 KB |
Output is correct |
3 |
Correct |
11 ms |
1536 KB |
Output is correct |
4 |
Correct |
44 ms |
11276 KB |
Output is correct |
5 |
Correct |
67 ms |
12556 KB |
Output is correct |
6 |
Correct |
69 ms |
12516 KB |
Output is correct |
7 |
Correct |
56 ms |
11732 KB |
Output is correct |
8 |
Correct |
56 ms |
11772 KB |
Output is correct |
9 |
Correct |
71 ms |
12660 KB |
Output is correct |
10 |
Correct |
68 ms |
12656 KB |
Output is correct |
11 |
Correct |
68 ms |
12516 KB |
Output is correct |
12 |
Correct |
70 ms |
12660 KB |
Output is correct |
13 |
Correct |
80 ms |
12496 KB |
Output is correct |
14 |
Correct |
67 ms |
12660 KB |
Output is correct |
15 |
Correct |
72 ms |
12544 KB |
Output is correct |
16 |
Correct |
63 ms |
12772 KB |
Output is correct |
17 |
Correct |
84 ms |
12296 KB |
Output is correct |
18 |
Correct |
76 ms |
12148 KB |
Output is correct |
19 |
Correct |
84 ms |
12236 KB |
Output is correct |
20 |
Correct |
59 ms |
12268 KB |
Output is correct |
21 |
Correct |
92 ms |
12156 KB |
Output is correct |
22 |
Correct |
76 ms |
12380 KB |
Output is correct |
23 |
Correct |
55 ms |
11388 KB |
Output is correct |
24 |
Correct |
49 ms |
11444 KB |
Output is correct |
25 |
Correct |
75 ms |
11604 KB |
Output is correct |
26 |
Correct |
53 ms |
11392 KB |
Output is correct |
27 |
Correct |
74 ms |
11900 KB |
Output is correct |
28 |
Correct |
67 ms |
11644 KB |
Output is correct |
29 |
Correct |
81 ms |
11900 KB |
Output is correct |
30 |
Correct |
57 ms |
11764 KB |
Output is correct |
31 |
Correct |
51 ms |
11260 KB |
Output is correct |
32 |
Correct |
50 ms |
11324 KB |
Output is correct |
33 |
Correct |
52 ms |
11468 KB |
Output is correct |
34 |
Correct |
77 ms |
11588 KB |
Output is correct |
35 |
Correct |
55 ms |
11880 KB |
Output is correct |
36 |
Correct |
66 ms |
12000 KB |
Output is correct |
37 |
Correct |
55 ms |
12020 KB |
Output is correct |
38 |
Correct |
60 ms |
11744 KB |
Output is correct |
39 |
Correct |
64 ms |
11840 KB |
Output is correct |
40 |
Correct |
61 ms |
11776 KB |
Output is correct |
41 |
Correct |
62 ms |
12020 KB |
Output is correct |
42 |
Correct |
69 ms |
12116 KB |
Output is correct |
43 |
Correct |
69 ms |
11900 KB |
Output is correct |
44 |
Correct |
75 ms |
12024 KB |
Output is correct |
45 |
Correct |
80 ms |
12180 KB |
Output is correct |
46 |
Correct |
71 ms |
12336 KB |
Output is correct |
47 |
Correct |
61 ms |
11860 KB |
Output is correct |
48 |
Correct |
69 ms |
11668 KB |
Output is correct |
49 |
Correct |
57 ms |
11644 KB |
Output is correct |
50 |
Correct |
60 ms |
11764 KB |
Output is correct |
51 |
Correct |
74 ms |
11280 KB |
Output is correct |
52 |
Correct |
52 ms |
11452 KB |
Output is correct |
53 |
Correct |
54 ms |
11156 KB |
Output is correct |
54 |
Correct |
55 ms |
11304 KB |
Output is correct |
55 |
Correct |
55 ms |
11272 KB |
Output is correct |
56 |
Correct |
51 ms |
11300 KB |
Output is correct |
57 |
Correct |
55 ms |
11380 KB |
Output is correct |
58 |
Correct |
55 ms |
11380 KB |
Output is correct |
59 |
Correct |
56 ms |
11492 KB |
Output is correct |
60 |
Correct |
67 ms |
11516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
11236 KB |
Output is correct |
2 |
Correct |
61 ms |
11596 KB |
Output is correct |
3 |
Correct |
10 ms |
1632 KB |
Output is correct |
4 |
Correct |
46 ms |
11412 KB |
Output is correct |
5 |
Correct |
68 ms |
12636 KB |
Output is correct |
6 |
Execution timed out |
3083 ms |
11684 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |