답안 #41827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41827 2018-02-21T09:55:34 Z krauch Amusement Park (JOI17_amusement_park) C++14
82 / 100
40 ms 5608 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);
    forn(i, 0, m - 1)
        --A[i], --B[i];
}


#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 sz(a) (int)a.size()
#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;
    bool ok = 0;
    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 - 1);
    }
    forn(i, 1, n) u[i] = 0;
    dfs2(st, stval);

    ll res = 0;
    forn(i, 0, 60) {
        res |= (ans[i] << ll(i));
    }
    forn(i, 0, m - 1)
        --A[i], --B[i];
    return res;
}


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

Compilation message

Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:50:10: warning: unused variable 'ok' [-Wunused-variable]
     bool ok = 0;
          ^
Ioi.cpp: At global scope:
Ioi.cpp:16:11: warning: 'X' defined but not used [-Wunused-variable]
 static ll X, sz[MAXN], lvl[MAXN], ans[66];
           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1628 KB Output is correct
2 Correct 4 ms 1892 KB Output is correct
3 Correct 4 ms 2076 KB Output is correct
4 Correct 4 ms 2116 KB Output is correct
5 Correct 5 ms 2136 KB Output is correct
6 Correct 5 ms 2136 KB Output is correct
7 Correct 6 ms 2212 KB Output is correct
8 Correct 6 ms 2304 KB Output is correct
9 Correct 6 ms 2332 KB Output is correct
10 Correct 4 ms 2344 KB Output is correct
11 Correct 7 ms 2592 KB Output is correct
12 Correct 4 ms 2592 KB Output is correct
13 Correct 4 ms 2592 KB Output is correct
14 Correct 4 ms 2592 KB Output is correct
15 Correct 4 ms 2592 KB Output is correct
16 Correct 4 ms 2592 KB Output is correct
17 Correct 4 ms 2592 KB Output is correct
18 Correct 4 ms 2592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 5140 KB Output is correct
2 Correct 32 ms 5356 KB Output is correct
3 Correct 40 ms 5384 KB Output is correct
4 Correct 19 ms 5408 KB Output is correct
5 Correct 18 ms 5408 KB Output is correct
6 Correct 19 ms 5408 KB Output is correct
7 Correct 20 ms 5408 KB Output is correct
8 Correct 19 ms 5408 KB Output is correct
9 Correct 19 ms 5408 KB Output is correct
10 Correct 17 ms 5408 KB Output is correct
11 Correct 19 ms 5408 KB Output is correct
12 Correct 19 ms 5408 KB Output is correct
13 Correct 17 ms 5408 KB Output is correct
14 Correct 30 ms 5408 KB Output is correct
15 Correct 18 ms 5408 KB Output is correct
16 Correct 22 ms 5408 KB Output is correct
17 Correct 19 ms 5408 KB Output is correct
18 Correct 22 ms 5408 KB Output is correct
19 Correct 19 ms 5408 KB Output is correct
20 Correct 17 ms 5408 KB Output is correct
21 Correct 24 ms 5408 KB Output is correct
22 Correct 23 ms 5408 KB Output is correct
23 Correct 20 ms 5408 KB Output is correct
24 Correct 23 ms 5408 KB Output is correct
25 Correct 20 ms 5408 KB Output is correct
26 Correct 19 ms 5408 KB Output is correct
27 Correct 19 ms 5408 KB Output is correct
28 Correct 22 ms 5408 KB Output is correct
29 Correct 17 ms 5408 KB Output is correct
30 Correct 19 ms 5408 KB Output is correct
31 Correct 4 ms 5408 KB Output is correct
32 Correct 4 ms 5408 KB Output is correct
33 Correct 4 ms 5408 KB Output is correct
34 Correct 4 ms 5408 KB Output is correct
35 Correct 4 ms 5408 KB Output is correct
36 Correct 4 ms 5408 KB Output is correct
37 Correct 4 ms 5408 KB Output is correct
38 Correct 4 ms 5408 KB Output is correct
39 Correct 4 ms 5408 KB Output is correct
40 Correct 4 ms 5408 KB Output is correct
41 Correct 4 ms 5408 KB Output is correct
42 Correct 4 ms 5408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5408 KB Output is correct
2 Correct 4 ms 5408 KB Output is correct
3 Correct 4 ms 5408 KB Output is correct
4 Correct 5 ms 5408 KB Output is correct
5 Correct 6 ms 5408 KB Output is correct
6 Correct 6 ms 5408 KB Output is correct
7 Correct 6 ms 5408 KB Output is correct
8 Correct 5 ms 5408 KB Output is correct
9 Correct 17 ms 5408 KB Output is correct
10 Correct 20 ms 5408 KB Output is correct
11 Correct 15 ms 5408 KB Output is correct
12 Correct 4 ms 5408 KB Output is correct
13 Correct 4 ms 5408 KB Output is correct
14 Correct 4 ms 5408 KB Output is correct
15 Correct 4 ms 5408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 5408 KB Output is correct
2 Partially correct 28 ms 5408 KB Partially correct
3 Correct 36 ms 5508 KB Output is correct
4 Correct 19 ms 5608 KB Output is correct
5 Correct 19 ms 5608 KB Output is correct
6 Correct 18 ms 5608 KB Output is correct
7 Correct 19 ms 5608 KB Output is correct
8 Correct 19 ms 5608 KB Output is correct
9 Correct 19 ms 5608 KB Output is correct
10 Correct 19 ms 5608 KB Output is correct
11 Correct 17 ms 5608 KB Output is correct
12 Correct 17 ms 5608 KB Output is correct
13 Correct 17 ms 5608 KB Output is correct
14 Correct 18 ms 5608 KB Output is correct
15 Partially correct 17 ms 5608 KB Partially correct
16 Correct 18 ms 5608 KB Output is correct
17 Correct 18 ms 5608 KB Output is correct
18 Partially correct 17 ms 5608 KB Partially correct
19 Partially correct 20 ms 5608 KB Partially correct
20 Correct 15 ms 5608 KB Output is correct
21 Correct 17 ms 5608 KB Output is correct
22 Correct 19 ms 5608 KB Output is correct
23 Correct 18 ms 5608 KB Output is correct
24 Correct 19 ms 5608 KB Output is correct
25 Correct 23 ms 5608 KB Output is correct
26 Correct 20 ms 5608 KB Output is correct
27 Correct 19 ms 5608 KB Output is correct
28 Correct 18 ms 5608 KB Output is correct
29 Correct 17 ms 5608 KB Output is correct
30 Correct 22 ms 5608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 5608 KB Output is correct
2 Correct 39 ms 5608 KB Output is correct
3 Correct 33 ms 5608 KB Output is correct
4 Correct 22 ms 5608 KB Output is correct
5 Correct 19 ms 5608 KB Output is correct
6 Correct 19 ms 5608 KB Output is correct
7 Correct 19 ms 5608 KB Output is correct
8 Correct 19 ms 5608 KB Output is correct
9 Correct 19 ms 5608 KB Output is correct
10 Correct 17 ms 5608 KB Output is correct
11 Correct 20 ms 5608 KB Output is correct
12 Correct 17 ms 5608 KB Output is correct
13 Correct 17 ms 5608 KB Output is correct
14 Correct 18 ms 5608 KB Output is correct
15 Correct 19 ms 5608 KB Output is correct
16 Incorrect 22 ms 5608 KB Output isn't correct
17 Halted 0 ms 0 KB -