답안 #257513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257513 2020-08-04T11:18:11 Z mhy908 Snowy Roads (JOI16_snowy) C++14
0 / 100
20 ms 1388 KB
#include "Anyalib.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
static int getL;

static int n, MAXD=10, re;
static int buc[510], d[510], cnt[510];
static vector<pii> link[510];

static void dfs(int num, int par, int dep){
    d[num]=dep;
    if(dep%MAXD==0)buc[num]=++re;
    for(auto i:link[num]){
        if(i.F==par)continue;
        dfs(i.F, num, dep+1);
    }
}

void InitAnya(int N, int A[], int B[]){
    n=N;
    for(int i=0; i<n-1; i++){
        link[A[i]].eb(B[i], i+1);
        link[B[i]].eb(A[i], i+1);
    }
    dfs(0, -1, 0);
}

static void dfs2(int num, int par, int dis){
    if(d[num]%MAXD==0){
        int tmp=dis;
        for(int i=buc[num]*10-10; i<buc[num]*10; i++){
            Save(i, tmp%2);
            tmp/=2;
        }
    }
    for(auto i:link[num]){
        if(i.F==par)continue;
        dfs2(i.F, num, dis+cnt[i.S]);
    }
}

void Anya(int C[]){
    for(int i=0; i<n-1; i++){
        cnt[i+1]=C[i];
        Save(500+i, C[i]);
    }
    dfs2(0, -1, 0);
}
#include "Borislib.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

static int n, MAXD=10, re;
static int par[510], ped[510], buc[510], d[510];
static vector<pii> link[510];

static void dfs(int num, int p, int dep){
    d[num]=dep;
    if(dep%MAXD==0)buc[num]=++re;
    for(auto i:link[num]){
        if(i.F==p)continue;
        par[i.F]=num, ped[i.F]=i.S;
        dfs(i.F, num, dep+1);
    }
}

void InitBoris(int N, int A[], int B[]){
    n=N;
    for(int i=0; i<n-1; i++){
        link[A[i]].eb(B[i], i+1);
        link[B[i]].eb(A[i], i+1);
    }
    dfs(0, -1, 0);
}

static int dfs2(int num){
    if(buc[num]){
        int ret=0;
        for(int i=buc[num]*10-1; i>=buc[num]*10-10; i--){
            ret*=2;
            ret+=Ask(i);
        }
        return ret;
    }
    return dfs2(par[num])+Ask(ped[num]+500);
}

int Boris(int city){
    return dfs2(city);
}

Compilation message

Anya.cpp:10:12: warning: 'getL' defined but not used [-Wunused-variable]
 static int getL;
            ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 992 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1052 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 1388 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 980 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -