#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
namespace std {
template <int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Dimension must be positive");
template <typename... Args>
Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}
};
template <typename T>
struct Vec<1, T> : public vector<T> {
Vec(int n = 0, T val = T()) : std::vector<T>(n, val) {}
};
/* Example
Vec<4, int64_t> f(n, k, 2, 2); // = f[n][k][2][2];
Vec<2, int> adj(n); // graph
*/
template <class Fun>
class y_combinator_result {
Fun fun_;
public:
template <class T>
explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {}
template <class... Args>
decltype(auto) operator()(Args &&...args) {
return fun_(std::ref(*this), std::forward<Args>(args)...);
}
};
template <class Fun>
decltype(auto) y_combinator(Fun &&fun) {
return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}
/* Example
auto fun = y_combinator([&](auto self, int x) -> void {
self(x + 1);
});
*/
} // namespace std
namespace {
int FunctionExample(int i, int A) {
return i % A;
}
} // namespace
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V) {
vector<vector<pair<int, int>>> adj(N);
for (int i = 0; i < M; i++) adj[U[i]].emplace_back(V[i], i);
for (int i = 0; i < M; i++) adj[V[i]].emplace_back(U[i], i);
vector<int> depth(M, -1);
vector<int> d(N, -1);
if (A == 4) A = 3;
if (A == 3) {
queue<int> q;
q.emplace(0);
d[0] = 0;
while (q.size()) {
int u = q.front();
q.pop();
for (auto &&[v, i] : adj[u]) {
if (d[v] == -1) {
d[v] = d[u] + 1;
depth[i] = d[u];
q.emplace(v);
}
}
}
vector<int> ans(M);
for (int i = 0; i < M; i++) {
if (depth[i] == -1) {
if (d[U[i]] == d[V[i]]) {
ans[i] = d[U[i]] % 3;
} else {
ans[i] = min(d[U[i]], d[V[i]]) % 3;
}
} else {
ans[i] = depth[i] % 3;
}
}
return ans;
}
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace std {
template <int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Dimension must be positive");
template <typename... Args>
Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}
};
template <typename T>
struct Vec<1, T> : public vector<T> {
Vec(int n = 0, T val = T()) : std::vector<T>(n, val) {}
};
/* Example
Vec<4, int64_t> f(n, k, 2, 2); // = f[n][k][2][2];
Vec<2, int> adj(n); // graph
*/
template <class Fun>
class y_combinator_result {
Fun fun_;
public:
template <class T>
explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {}
template <class... Args>
decltype(auto) operator()(Args &&...args) {
return fun_(std::ref(*this), std::forward<Args>(args)...);
}
};
template <class Fun>
decltype(auto) y_combinator(Fun &&fun) {
return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}
/* Example
auto fun = y_combinator([&](auto self, int x) -> void {
self(x + 1);
});
*/
} // namespace std
namespace {
int A, B;
} // namespace
void Init(int A, int B) {
::A = A;
::A = min(::A, 3);
::B = B;
}
int Move(std::vector<int> y) {
int cnt = 0;
for (int i = 0; i < A; i++) {
cnt += y[i] > 0;
}
if (cnt == 1) {
for (int i = 0; i < A; i++) {
if (y[i] > 0) return i;
}
} else {
for (int i = 0; i < A; i++) {
if (y[i] > 0 && y[(i + 1) % A] > 0) return i;
}
}
}
Compilation message
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:75:37: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
75 | for (auto &&[v, i] : adj[u]) {
| ^
Anthony.cpp:62:45: warning: control reaches end of non-void function [-Wreturn-type]
62 | vector<vector<pair<int, int>>> adj(N);
| ^
Anthony.cpp: At global scope:
Anthony.cpp:54:5: warning: 'int {anonymous}::FunctionExample(int, int)' defined but not used [-Wunused-function]
54 | int FunctionExample(int i, int A) {
| ^~~~~~~~~~~~~~~
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:78:1: warning: control reaches end of non-void function [-Wreturn-type]
78 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
15880 KB |
Output is correct |
2 |
Correct |
1 ms |
780 KB |
Output is correct |
3 |
Correct |
27 ms |
15396 KB |
Output is correct |
4 |
Correct |
45 ms |
17420 KB |
Output is correct |
5 |
Correct |
46 ms |
16760 KB |
Output is correct |
6 |
Correct |
32 ms |
15840 KB |
Output is correct |
7 |
Correct |
31 ms |
15604 KB |
Output is correct |
8 |
Correct |
34 ms |
16188 KB |
Output is correct |
9 |
Correct |
45 ms |
16256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
15880 KB |
Output is correct |
2 |
Correct |
1 ms |
780 KB |
Output is correct |
3 |
Correct |
27 ms |
15396 KB |
Output is correct |
4 |
Correct |
45 ms |
17420 KB |
Output is correct |
5 |
Correct |
46 ms |
16760 KB |
Output is correct |
6 |
Correct |
32 ms |
15840 KB |
Output is correct |
7 |
Correct |
31 ms |
15604 KB |
Output is correct |
8 |
Correct |
34 ms |
16188 KB |
Output is correct |
9 |
Correct |
45 ms |
16256 KB |
Output is correct |
10 |
Correct |
28 ms |
13624 KB |
Output is correct |
11 |
Correct |
28 ms |
13756 KB |
Output is correct |
12 |
Correct |
27 ms |
13644 KB |
Output is correct |
13 |
Correct |
27 ms |
13900 KB |
Output is correct |
14 |
Correct |
28 ms |
13888 KB |
Output is correct |
15 |
Correct |
31 ms |
14064 KB |
Output is correct |
16 |
Correct |
35 ms |
16252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
13556 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
25 ms |
12848 KB |
Output is correct |
4 |
Correct |
41 ms |
14520 KB |
Output is correct |
5 |
Correct |
34 ms |
14712 KB |
Output is correct |
6 |
Correct |
28 ms |
13660 KB |
Output is correct |
7 |
Correct |
28 ms |
13400 KB |
Output is correct |
8 |
Correct |
34 ms |
13952 KB |
Output is correct |
9 |
Correct |
32 ms |
14012 KB |
Output is correct |
10 |
Correct |
33 ms |
13908 KB |
Output is correct |
11 |
Correct |
32 ms |
13688 KB |
Output is correct |
12 |
Correct |
32 ms |
13680 KB |
Output is correct |
13 |
Correct |
34 ms |
14048 KB |
Output is correct |
14 |
Correct |
35 ms |
13876 KB |
Output is correct |
15 |
Correct |
34 ms |
13948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
13556 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
25 ms |
12848 KB |
Output is correct |
4 |
Correct |
41 ms |
14520 KB |
Output is correct |
5 |
Correct |
34 ms |
14712 KB |
Output is correct |
6 |
Correct |
28 ms |
13660 KB |
Output is correct |
7 |
Correct |
28 ms |
13400 KB |
Output is correct |
8 |
Correct |
34 ms |
13952 KB |
Output is correct |
9 |
Correct |
32 ms |
14012 KB |
Output is correct |
10 |
Correct |
33 ms |
13908 KB |
Output is correct |
11 |
Correct |
32 ms |
13688 KB |
Output is correct |
12 |
Correct |
32 ms |
13680 KB |
Output is correct |
13 |
Correct |
34 ms |
14048 KB |
Output is correct |
14 |
Correct |
35 ms |
13876 KB |
Output is correct |
15 |
Correct |
34 ms |
13948 KB |
Output is correct |
16 |
Correct |
24 ms |
11728 KB |
Output is correct |
17 |
Correct |
28 ms |
11716 KB |
Output is correct |
18 |
Correct |
26 ms |
11600 KB |
Output is correct |
19 |
Correct |
30 ms |
11576 KB |
Output is correct |
20 |
Correct |
30 ms |
12368 KB |
Output is correct |
21 |
Correct |
33 ms |
12368 KB |
Output is correct |
22 |
Correct |
35 ms |
14200 KB |
Output is correct |
23 |
Correct |
27 ms |
11836 KB |
Output is correct |
24 |
Correct |
27 ms |
11808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
3172 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
3176 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |