Submission #257314

# Submission time Handle Problem Language Result Execution time Memory
257314 2020-08-04T05:50:31 Z imeimi2000 None (JOI16_snowy) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

void Save(int, int);

const static int mod = 11, lg = 9;
static int A[501], B[501];
static vector<int> edge[501];
static vector<int> D[501];
static int par[501];

void dfs1(int x, int p, int d) {
    par[x] = p;
    if (d) D[d % mod].push_back(x);
    for (int i : edge[x]) {
        if (i == p) continue;
        dfs1(i, x, d + 1);
    }
}

static int ord[501];
void InitAnya(int n, int _A[], int _B[]) {
    for (int i = 0; i < n - 1; ++i) {
        A[i + 1] = _A[i] + 1;
        B[i + 1] = _B[i] + 1;
        edge[A[i]].push_back(B[i]);
        edge[B[i]].push_back(A[i]);
    }
    dfs1(1, 0, 0);
    for (int i = 1; i < n; ++i) {
        if (par[A[i]] == B[i]) swap(A[i], B[i]);
    }
    int mn = 0;
    for (int i = 1; i < mod; ++i) if (D[i].size() < D[mn].size()) mn = i;
    swap(D[0], D[mn]);
    memset(ord, -1, sizeof(ord));
    for (int i = 0; i < int(D[0].size()); ++i) {
        ord[D[0][i]] = i;
    }
}

static int dist[501];
static int pdis[501];
void dfs2(int x, int p, int d) {
    dist[x] = d;
    for (int i : edge[x]) {
        if (i == p) continue;
        dfs2(i, x, d + pdis[i]);
    }
}

void Anya(int n, int C[]) {
    for (int i = 1; i < n; ++i) {
        Save(i + n, pdis[B[i]] = C[i - 1]);
    }
    dfs2(1, 0, 0);
    for (int i = 1; i <= n; ++i) {
        int o = ord[i];
        if (o < 0) continue;
        for (int j = 0; j < lg; ++j) {
            Save(o * lg + j, dist[i] & 1);
            dist[i] >>= 1;
        }
    }
}
#include <bits/stdc++.h>

using namespace std;

int Ask(int);

const static int mod = 11, lg = 9;
static int A[501], B[501], n;
static vector<int> edge[501];
static vector<int> D[501];
static int par[501], pari[501];

void dfs1(int x, int p, int d) {
    par[x] = p;
    if (d) D[d % mod].push_back(x);
    for (int i : edge[x]) {
        if (i == p) continue;
        dfs1(i, x, d + 1);
    }
}

static int ord[501];
void InitBoris(int _n, int _A[], int _B[]) {
    n = _n;
    for (int i = 0; i < n - 1; ++i) {
        A[i + 1] = _A[i] + 1;
        B[i + 1] = _B[i] + 1;
        edge[A[i]].push_back(B[i]);
        edge[B[i]].push_back(A[i]);
    }
    dfs1(1, 0, 0);
    for (int i = 1; i < n; ++i) {
        if (par[A[i]] == B[i]) swap(A[i], B[i]);
        pari[B[i]] = i;
    }
    int mn = 0;
    for (int i = 1; i < mod; ++i) if (D[i].size() < D[mn].size()) mn = i;
    swap(D[0], D[mn]);
    memset(ord, -1, sizeof(ord));
    for (int i = 0; i < int(D[0].size()); ++i) {
        ord[D[0][i]] = i;
    }
}

int Boris(int x) {
    int ret = 0;
    while (x) {
        int o = ord[x];
        if (o < 0) {
            ret += Ask(pari[x] + n);
            x = par[x];
            continue;
        }
        int v = 0;
        for (int i = 0; i < lg; ++i) {
            v <<= 1;
            v |= Ask(o * lg + i);
        }
        ret += v;
    }
    return ret;
}

Compilation message

/tmp/ccmEtNLO.o: In function `main':
grader_anya.cpp:(.text.startup+0x196): undefined reference to `Anya(int*)'
collect2: error: ld returned 1 exit status