This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Anthony.h"
#include <cstdlib>
#include <vector>
using namespace std;
typedef vector<int> vi;
namespace A {
int min(int a, int b) { return a < b ? a : b; }
const int N = 20000;
int *ej[N], eo[N], dd[N], qu[N], n;
void init(int n_) {
n = n_;
for (int i = 0; i < n; i++)
ej[i] = (int *) malloc(2 * sizeof *ej[i]);
}
void append(int i, int j) {
int o = eo[i]++;
if (o >= 2 && (o & o - 1) == 0)
ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]);
ej[i][o] = j;
}
void bfs() {
for (int i = 0; i < n; i++)
dd[i] = n;
int cnt = 0;
dd[0] = 0, qu[cnt++] = 0;
for (int h = 0; h < cnt; h++) {
int i = qu[h], d = dd[i] + 1;
for (int o = eo[i]; o--; ) {
int j = ej[i][o];
if (dd[j] > d)
dd[j] = d, qu[cnt++] = j;
}
}
}
}
vi Mark(int n, int m, int a, int b, vi uu, vi vv) {
vi cc(m);
if (a >= 3 && b == 0) {
A::init(n);
for (int h = 0; h < m; h++)
A::append(uu[h], vv[h]), A::append(vv[h], uu[h]);
A::bfs();
for (int h = 0; h < m; h++)
cc[h] = A::min(A::dd[uu[h]], A::dd[vv[h]]) % 3;
} else {
}
return cc;
}
#include "Catherine.h"
#include <vector>
using namespace std;
typedef vector<int> vi;
namespace {
int c_;
}
void Init(int a, int b) {
a = b = a;
c_ = -1;
}
int Move(vi kk) {
int a = kk.size();
if (a == 3) {
if (c_ != -1)
kk[c_]++;
for (int c = 0; c < 3; c++)
if (kk[(c + 2) % 3] == 0 && kk[c] != 0)
return c;
} else
return -1;
return -1;
}
Compilation message (stderr)
Anthony.cpp: In function 'void A::append(int, int)':
Anthony.cpp:23:24: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
23 | if (o >= 2 && (o & o - 1) == 0)
| ~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |