Submission #41809

# Submission time Handle Problem Language Result Execution time Memory
41809 2018-02-21T09:24:08 Z krauch Amusement Park (JOI17_amusement_park) C++14
Compilation error
0 ms 0 KB
#include "Joi.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define eb emplace_back
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)

static const int MAXN = 2e4 + 6;

static int n, m, comp[MAXN], cnt;
static ll X, sz[MAXN];
static vector < int > g[MAXN];
static bool u[MAXN];

void dfs(int v) {
    u[v] = 1;
    for (auto to : g[v]) {
        if (u[to]) continue;
        if (sz[comp[v]] == 60)
            comp[to] = ++cnt;
        else
            comp[to] = comp[v];
        MessageBoard(to - 1, (X >> sz[comp[to]]) & 1);
        sz[comp[to]]++;
        dfs(to);
    }
}

void Joi(int _n, int _m, int A[], int B[], long long _x, int _t) {
    n = _n, m = _m;
    X = _x;
    forn(i, 0, m - 1) {
        A[i]++, B[i]++;
        g[A[i]].eb(B[i]);
        g[B[i]].eb(A[i]);
    }

    cnt = 1;
    comp[1] = 1;
    sz[comp[1]] = 1;
    MessageBoard(0, X & 1);
    dfs(1);
}


#ifdef krauch
int main() {
    return 0;
}
#endif
#include "Ioi.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define eb emplace_back
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)

static const int MAXN = 2e4 + 6;

static int n, m, comp[MAXN], cnt, par[MAXN], CUR;
static ll X, sz[MAXN], lvl[MAXN], ans[66];
static vector < int > g[MAXN];
static bool u[MAXN];

void dfs(int v) {
    CUR++;
    u[v] = 1;
    for (auto to : g[v]) {
        if (u[to]) continue;
        if (sz[comp[v]] == 60)
            comp[to] = ++cnt;
        else
            comp[to] = comp[v];
        lvl[to] = sz[comp[to]];
        sz[comp[to]]++;
        par[to] = v;
        dfs(to);
    }
}

void dfs2(int v, int val) {
    u[v] = 1;
    ans[lvl[v]] |= val;
    for (auto to : g[v]) {
        if (u[to] || comp[to] != comp[v]) continue;
        int toval = Move(to - 1);
        dfs2(to, toval);
        val = Move(v - 1);
    }
}

ll Ioi(int _n, int _m, int A[], int B[], int _p, int _v, int _t) {
    n = _n, m = _m;
    int st = _p + 1, stval = _v;
    forn(i, 0, m - 1) {
        A[i]++, B[i]++;
        g[A[i]].eb(B[i]);
        g[B[i]].eb(A[i]);
    }

    assert(sz(g[1]));
    cnt = 1;
    comp[1] = 1;
    sz[comp[1]] = 1;
    dfs(1);

    while (sz[comp[st]] != 60) {
        st = par[st];
        stval = Move(st - 1);
    }
    forn(i, 1, n) u[i] = 0;
    dfs2(st, stval);

    ll res = 0;
    forn(i, 0, 60) {
        res |= (ans[i] << ll(i));
    }
    return res;
}


#ifdef krauch
int main() {
    return 0;
}
#endif

Compilation message

In file included from /usr/include/c++/5/cassert:43:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:33,
                 from Ioi.cpp:2:
Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:55:19: error: 'sz' cannot be used as a function
     assert(sz(g[1]));
                   ^
Ioi.cpp: At global scope:
Ioi.cpp:15:11: warning: 'X' defined but not used [-Wunused-variable]
 static ll X, sz[MAXN], lvl[MAXN], ans[66];
           ^