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 <bits/stdc++.h>
using namespace std;
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V) {
std::vector<int> X(M, -1);
vector<vector<pair<int, int>>> adj(N);
for (int i = 0; i < M; ++i) {
adj[U[i]].push_back({V[i], i});
adj[V[i]].push_back({U[i], i});
}
vector<int> dist(N, -1), par(N), e(N, -1), dp(N, -1);
dist[0] = 0;
queue<int> q;
q.push(0);
while (!q.empty()) {
int v = q.front();
q.pop();
if (A == 2) {
int x = v;
if (par[x] && adj[par[x]].size() >= 3) {
if (X[e[par[x]]] == 1) {
dp[x] = 0;
} else {
dp[x] = 1;
}
} else if (x == 0) {
dp[x] = -1;
} else {
dp[x] = (1 + dp[par[x]]) % 6;
}
if (dp[x] >= 0) {
X[e[x]] = "010011"[dp[x]] - '0';
}
}
for (auto [to, i] : adj[v]) {
if (dist[to] == -1) {
dist[to] = dist[v] + 1;
par[to] = v;
e[to] = i;
q.push(to);
}
if (dist[to] >= dist[v] && A >= 3) {
X[i] = dist[v] % 3;
}
}
}
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
string code = "010011", adj;
int A, B, e = -1;
bool known = false;
}
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(std::vector<int> y) {
vector<int> yy = y;
if (e != -1) {
yy[e] += 1;
}
int deg = accumulate(yy.begin(), yy.end(), 0);
if (A >= 3) {
int fi = -1, se = -1, cnt = 0;
for (int i = 0; i < A; ++i) {
if (yy[i]) {
fi = fi == -1 ? i : fi;
se = i;
cnt += 1;
}
}
if (fi != 0 || se != 2) {
return e = fi;
} else {
return e = se;
}
} else {
if (deg == 2) {
if (known) {
return e = find(y.begin(), y.end(), 1) - y.begin();
}
for (int i = 0; i < A; ++i) {
adj += string(y[i], char('0' + i));
}
if (adj.size() == 5) {
known = true;
string s = code + code;
for (int i = 0; i < 6; ++i) {
if (adj == s.substr(i, 5)) {
return -1;
}
}
return e = find(y.begin(), y.end(), 1) - y.begin();
} else {
return e = adj.back() - '0';
}
} else {
known = true;
int u = find(yy.begin(), yy.end(), 1) - yy.begin();
return u == e ? -1 : e = u;
}
}
}
# | 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... |