Submission #257531

# Submission time Handle Problem Language Result Execution time Memory
257531 2020-08-04T11:35:07 Z mhy908 None (JOI16_snowy) C++14
100 / 100
25 ms 1556 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], sz[510], cnt[510];
static vector<pii> link[510];

static void dfs(int num, int par){
    sz[num]=1;
    if(par==-1)buc[num]=++re;
    for(auto i:link[num]){
        if(i.F==par)continue;
        dfs(i.F, num);
        sz[num]+=sz[i.F];
    }
    if(sz[num]>=10&&par>=0)buc[num]=++re, sz[num]=0;
}

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

static void dfs2(int num, int par, int dis){
    if(buc[num]){
        int tmp=dis;
        for(int i=buc[num]*9-9; i<buc[num]*9; i++){
            assert(i<=500);
            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(501+i, C[i]);
    }
    dfs2(0, -1, 0);
}
/*
3
0 1
1 2
1
11
3
0 1 2
*/
#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], sz[510];
static vector<pii> link[510];

static void dfs(int num, int p){
    sz[num]=1;
    if(p==-1)buc[num]=++re;
    for(auto i:link[num]){
        if(i.F==p)continue;
        dfs(i.F, num);
        par[i.F]=num, ped[i.F]=i.S;
        sz[num]+=sz[i.F];
    }
    if(sz[num]>=10&&par>=0)buc[num]=++re, sz[num]=0;
}

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

static int dfs2(int num){
    if(buc[num]){
        int ret=0;
        for(int i=buc[num]*9-1; i>=buc[num]*9-9; 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:12:15: warning: 'MAXD' defined but not used [-Wunused-variable]
 static int n, MAXD=10, re;
               ^~~~
Anya.cpp:10:12: warning: 'getL' defined but not used [-Wunused-variable]
 static int getL;
            ^~~~

Boris.cpp:11:15: warning: 'MAXD' defined but not used [-Wunused-variable]
 static int n, MAXD=10, re;
               ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 996 KB Output is correct
2 Correct 2 ms 916 KB Output is correct
3 Correct 4 ms 976 KB Output is correct
4 Correct 6 ms 1212 KB Output is correct
5 Correct 9 ms 1188 KB Output is correct
6 Correct 6 ms 1048 KB Output is correct
7 Correct 11 ms 1048 KB Output is correct
8 Correct 10 ms 1184 KB Output is correct
9 Correct 7 ms 1188 KB Output is correct
10 Correct 6 ms 1048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1188 KB Output is correct
2 Correct 7 ms 1440 KB Output is correct
3 Correct 8 ms 1432 KB Output is correct
4 Correct 7 ms 1432 KB Output is correct
5 Correct 8 ms 1440 KB Output is correct
6 Correct 8 ms 1308 KB Output is correct
7 Correct 7 ms 1432 KB Output is correct
8 Correct 8 ms 1052 KB Output is correct
9 Correct 8 ms 1436 KB Output is correct
10 Correct 7 ms 1308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1396 KB Output is correct
2 Correct 15 ms 1280 KB Output is correct
3 Correct 17 ms 1396 KB Output is correct
4 Correct 17 ms 1368 KB Output is correct
5 Correct 17 ms 1400 KB Output is correct
6 Correct 15 ms 1336 KB Output is correct
7 Correct 15 ms 1336 KB Output is correct
8 Correct 16 ms 1336 KB Output is correct
9 Correct 16 ms 1280 KB Output is correct
10 Correct 15 ms 1336 KB Output is correct
11 Correct 15 ms 1392 KB Output is correct
12 Correct 15 ms 1336 KB Output is correct
13 Correct 15 ms 1388 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 15 ms 1388 KB Output is correct
16 Correct 15 ms 1280 KB Output is correct
17 Correct 15 ms 1336 KB Output is correct
18 Correct 15 ms 1400 KB Output is correct
19 Correct 15 ms 1280 KB Output is correct
20 Correct 15 ms 1392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1344 KB Output is correct
2 Correct 15 ms 1332 KB Output is correct
3 Correct 15 ms 1416 KB Output is correct
4 Correct 15 ms 1332 KB Output is correct
5 Correct 17 ms 1336 KB Output is correct
6 Correct 17 ms 1332 KB Output is correct
7 Correct 22 ms 1280 KB Output is correct
8 Correct 15 ms 1280 KB Output is correct
9 Correct 16 ms 1280 KB Output is correct
10 Correct 15 ms 1420 KB Output is correct
11 Correct 16 ms 1404 KB Output is correct
12 Correct 15 ms 1280 KB Output is correct
13 Correct 17 ms 1404 KB Output is correct
14 Correct 25 ms 1280 KB Output is correct
15 Correct 18 ms 1280 KB Output is correct
16 Correct 13 ms 1420 KB Output is correct
17 Correct 17 ms 1400 KB Output is correct
18 Correct 19 ms 1152 KB Output is correct
19 Correct 16 ms 1408 KB Output is correct
20 Correct 15 ms 1280 KB Output is correct
21 Correct 16 ms 1416 KB Output is correct
22 Correct 17 ms 1416 KB Output is correct
23 Correct 16 ms 1332 KB Output is correct
24 Correct 15 ms 1280 KB Output is correct
25 Correct 18 ms 1280 KB Output is correct
26 Correct 16 ms 1400 KB Output is correct
27 Correct 18 ms 1332 KB Output is correct
28 Correct 16 ms 1416 KB Output is correct
29 Correct 16 ms 1280 KB Output is correct
30 Correct 16 ms 1332 KB Output is correct
31 Correct 16 ms 1332 KB Output is correct
32 Correct 16 ms 1420 KB Output is correct
33 Correct 17 ms 1404 KB Output is correct
34 Correct 16 ms 1332 KB Output is correct
35 Correct 15 ms 1332 KB Output is correct
36 Correct 16 ms 1280 KB Output is correct
37 Correct 15 ms 1420 KB Output is correct
38 Correct 17 ms 1336 KB Output is correct
39 Correct 16 ms 1424 KB Output is correct
40 Correct 15 ms 1556 KB Output is correct
41 Correct 16 ms 1420 KB Output is correct
42 Correct 15 ms 1280 KB Output is correct
43 Correct 13 ms 1428 KB Output is correct
44 Correct 16 ms 1332 KB Output is correct
45 Correct 13 ms 1280 KB Output is correct
46 Correct 13 ms 1424 KB Output is correct
47 Correct 15 ms 1420 KB Output is correct
48 Correct 15 ms 1332 KB Output is correct
49 Correct 15 ms 1552 KB Output is correct
50 Correct 17 ms 1416 KB Output is correct