답안 #491335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491335 2021-12-01T15:13:39 Z blue Amusement Park (JOI17_amusement_park) C++17
18 / 100
27 ms 4988 KB
#include "Joi.h"
#include <vector>
using namespace std;

using vi = vector<int>;
using ll = long long;

static const int maxN = 10'000;

static vi edge[maxN];

static vi parent(maxN);
static vi children[maxN];

static const int lg = 60;

static int ct = -1;
static vi bits(lg);

static vi visit(maxN, 0);

static void dfs(int u)
{
    ct = (ct + 1) % lg;
    MessageBoard(u, bits[ct]);
    visit[u] = 1;

    for(int v: edge[u])
    {
        if(visit[v]) continue;
        dfs(v);
    }
}

void Joi(int N, int M, int A[], int B[], ll X, int T)
{
    for(int e = 0; e < lg; e++)
    {
        bits[e] = X % 2LL;
        X /= 2LL;
    }

    for(int j = 0; j < M; j++)
    {
        edge[A[j]].push_back(B[j]);
        edge[B[j]].push_back(A[j]);
    }

    dfs(0);
}
#include "Ioi.h"
#include <vector>
#include <cassert>
using namespace std;

using vi = vector<int>;
using ll = long long;

static const int maxN = 10'000;

static vi edge[maxN];

static vi parent(maxN, -1);
static vi children[maxN];

static const int lg = 60;

static int ct = -1;
static vi bits(lg);

static vi visit(maxN, 0);

static vi ind(maxN);

#define sz(x) ((int)x.size())

static void dfs(int u)
{
    ct = (ct + 1) % lg;
    ind[u] = ct;
    visit[u] = 1;

    for(int v: edge[u])
    {
        if(visit[v]) continue;
        parent[v] = u;
        children[u].push_back(v);
        dfs(v);
    }
}

static ll X = 0;

static ll pow2[lg];

static void setbit(int b, int v)
{
    if(v)
        X += pow2[b];
}

static int mv;

static int set_count = 0;

static void dfs2(int u)
{
    if(set_count >= 60) return;
    set_count++;

    setbit(ind[u], mv);

    for(int v: children[u])
    {
        mv = Move(v);
        dfs2(v);
        mv = Move(u);
    }
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
    pow2[0] = 1;
    for(int e = 1; e < lg; e++)
        pow2[e] = 2LL * pow2[e-1];

    for(int j = 0; j < M; j++)
    {
        edge[A[j]].push_back(B[j]);
        edge[B[j]].push_back(A[j]);
    }

    dfs(0);

    if(P == 0)
    {
        mv = V;
    }
    while(P != 0)
    {
        P = parent[P];
        mv = Move(P);
    }

    int f = 0;
    for(int i = 0; i < N; i++) f += sz(children[i]);
    assert(f == N-1);

    dfs2(0);

    return X;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1768 KB Output is correct
2 Correct 1 ms 1768 KB Output is correct
3 Correct 2 ms 1772 KB Output is correct
4 Correct 2 ms 1780 KB Output is correct
5 Correct 2 ms 1780 KB Output is correct
6 Correct 2 ms 1776 KB Output is correct
7 Correct 2 ms 1780 KB Output is correct
8 Correct 2 ms 1780 KB Output is correct
9 Correct 3 ms 1780 KB Output is correct
10 Correct 2 ms 1776 KB Output is correct
11 Correct 5 ms 2068 KB Output is correct
12 Correct 2 ms 1776 KB Output is correct
13 Correct 2 ms 1700 KB Output is correct
14 Correct 2 ms 1772 KB Output is correct
15 Correct 2 ms 1772 KB Output is correct
16 Correct 2 ms 1772 KB Output is correct
17 Correct 2 ms 1780 KB Output is correct
18 Correct 2 ms 1780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 4988 KB Output is correct
2 Correct 24 ms 4964 KB Output is correct
3 Correct 26 ms 4944 KB Output is correct
4 Correct 15 ms 3468 KB Output is correct
5 Correct 19 ms 3988 KB Output is correct
6 Correct 14 ms 3828 KB Output is correct
7 Correct 14 ms 3876 KB Output is correct
8 Correct 15 ms 3848 KB Output is correct
9 Correct 14 ms 3832 KB Output is correct
10 Correct 15 ms 3472 KB Output is correct
11 Correct 18 ms 3464 KB Output is correct
12 Correct 15 ms 3340 KB Output is correct
13 Correct 15 ms 3388 KB Output is correct
14 Correct 13 ms 3364 KB Output is correct
15 Correct 16 ms 3552 KB Output is correct
16 Correct 14 ms 3588 KB Output is correct
17 Correct 14 ms 3468 KB Output is correct
18 Correct 16 ms 3480 KB Output is correct
19 Correct 14 ms 3476 KB Output is correct
20 Correct 12 ms 3820 KB Output is correct
21 Correct 13 ms 3848 KB Output is correct
22 Correct 15 ms 3584 KB Output is correct
23 Correct 18 ms 3848 KB Output is correct
24 Correct 15 ms 3568 KB Output is correct
25 Correct 15 ms 3824 KB Output is correct
26 Correct 15 ms 3872 KB Output is correct
27 Correct 15 ms 3860 KB Output is correct
28 Correct 14 ms 3920 KB Output is correct
29 Correct 14 ms 3672 KB Output is correct
30 Correct 15 ms 3696 KB Output is correct
31 Correct 2 ms 1776 KB Output is correct
32 Correct 2 ms 1768 KB Output is correct
33 Correct 2 ms 1776 KB Output is correct
34 Correct 2 ms 1776 KB Output is correct
35 Correct 2 ms 1768 KB Output is correct
36 Correct 2 ms 1776 KB Output is correct
37 Correct 2 ms 1772 KB Output is correct
38 Correct 2 ms 1756 KB Output is correct
39 Correct 2 ms 1768 KB Output is correct
40 Correct 2 ms 1768 KB Output is correct
41 Correct 2 ms 1824 KB Output is correct
42 Correct 2 ms 1780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1780 KB Output is correct
2 Correct 2 ms 1776 KB Output is correct
3 Correct 2 ms 1776 KB Output is correct
4 Correct 4 ms 2192 KB Output is correct
5 Incorrect 3 ms 2208 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 4960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 4932 KB Output isn't correct
2 Halted 0 ms 0 KB -