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 "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const int N = 500;
int n;
int pr[N], c[N];
vector<int> cands;
vector<array<int, 2>> g[N];
void dfs(int u, int cur = 11) {
if (cur == 11) {
cur = 0;
cands.push_back(u);
} else {
++cur;
}
for (auto [v, i] : g[u]) {
if (v != pr[u]) {
pr[v] = u;
dfs(v, cur);
}
}
}
void color(int u, int *C) {
for (auto [v, i] : g[u]) {
if (v != pr[u]) {
Save(v, C[i]);
c[v] = c[u] + C[i];
color(v, C);
}
}
}
}
void InitAnya(int N, int *A, int *B) {
n = N;
for (int i = 0; i < N - 1; ++i) {
g[A[i]].push_back({B[i], i});
g[B[i]].push_back({A[i], i});
}
dfs(0);
}
void Anya(int *C) {
c[0] = 0;
color(0, C);
for (int i = 0; i < cands.size(); ++i) {
for (int j = 0; j < 9; ++j) {
Save(500 + i * 9 + j, c[cands[i]] >> j & 1);
}
}
}
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const int N = 500;
int n, p = 0;
int pr[N], c[N], spec[N];
vector<int> g[N];
void dfs(int u, int cur = 11) {
if (cur == 11) {
cur = 0;
spec[u] = ++p;
} else {
++cur;
}
for (int v : g[u]) {
if (v != pr[u]) {
pr[v] = u;
dfs(v, cur);
}
}
}
}
void InitBoris(int N, int *A, int *B) {
n = N;
for (int i = 0; i < N - 1; ++i) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
dfs(0);
}
int Boris(int u) {
int res = 0;
while (!spec[u]) {
res += Ask(u);
u = pr[u];
}
if (spec[u]) {
for (int j = 0; j < 9; ++j) {
res += Ask(500 + 9 * (spec[u] - 1) + j) << j;
}
}
return res;
}
Compilation message (stderr)
Anya.cpp: In function 'void Anya(int*)':
Anya.cpp:53:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for (int i = 0; i < cands.size(); ++i) {
| ~~^~~~~~~~~~~~~~
Boris.cpp:11:14: warning: '{anonymous}::c' defined but not used [-Wunused-variable]
11 | int pr[N], c[N], spec[N];
| ^
# | 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... |