답안 #41755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41755 2018-02-21T07:27:29 Z krauch Amusement Park (JOI17_amusement_park) C++14
0 / 100
14 ms 4144 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, (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(1, 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];
static ll X, sz[MAXN], lvl[MAXN], ans[66];
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];
        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);
        dfs2(to, toval);
        val = Move(v);
    }
}

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]);
    }

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

    while (sz[comp[st]] != 60) {
        st = par[st];
        stval = Move(st);
    }
    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

Ioi.cpp:15:11: warning: 'X' defined but not used [-Wunused-variable]
 static ll X, sz[MAXN], lvl[MAXN], ans[66];
           ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1592 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 3736 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 3736 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 4144 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 4144 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -