Submission #513708

# Submission time Handle Problem Language Result Execution time Memory
513708 2022-01-17T12:39:26 Z 79brue None (JOI16_snowy) C++14
100 / 100
16 ms 1832 KB
#include "Anyalib.h"
#include <bits/stdc++.h>

using namespace std;

static int n;
static vector<int> link[502];
static bool mark[502];
static int depth[502];
static int numLoc[502], locCnt;
static int low[502];

static int dfs(int x, int par = -1){
    int maxDepth = 0;
    for(auto y: link[x]){
        if(y == par) continue;
        depth[y] = depth[x] + 1;
        maxDepth = max(dfs(y, x)+1, maxDepth);
    }
    if(maxDepth == 11 || x==0){
        mark[x] = 1;
        numLoc[x] = locCnt;
        locCnt += 9;
        maxDepth = 0;
    }
    return maxDepth;
}

void InitAnya(int N, int A[], int B[]){
    n = N;
    for(int i=0; i<N-1; i++) link[A[i]].push_back(B[i]), link[B[i]].push_back(A[i]);
    locCnt = n;
    dfs(0);
    for(int i=0; i<N-1; i++){
        if(depth[A[i]] > depth[B[i]]) low[i] = A[i];
        else low[i] = B[i];
    }
}

int DP[502];

void dfs2(int x, int par = -1){
    for(auto y: link[x]){
        if(y == par) continue;
        DP[y] += DP[x];
        dfs2(y, x);
    }
}

void Anya(int C[]){
    memset(DP, 0, sizeof(DP));
    for(int i=0; i<n-1; i++){
        DP[low[i]] = C[i];
    }
    dfs2(0);

    for(int i=0; i<n-1; i++) Save(i, C[i]);
    for(int i=0; i<n; i++){
        if(mark[i]){
            for(int j=numLoc[i]; j<numLoc[i]+9; j++){
                int x = j-numLoc[i];
                Save(j, (DP[i]>>x)&1);
            }
        }
    }
}
#include "Borislib.h"
#include <bits/stdc++.h>

using namespace std;

static int n;
static vector<int> link[502];
static bool mark[502];
static int depth[502];
static int numLoc[502], locCnt;
static int low[502], edge[502], p[502];

static int dfs(int x, int par = -1){
    int maxDepth = 0;
    for(auto y: link[x]){
        if(y == par) continue;
        depth[y] = depth[x] + 1;
        p[y] = x;
        maxDepth = max(dfs(y, x)+1, maxDepth);
    }
    if(maxDepth == 11 || x==0){
        mark[x] = 1;
        numLoc[x] = locCnt;
        locCnt += 9;
        maxDepth = 0;
    }
    return maxDepth;
}

void InitBoris(int N , int A[] , int B[]) {
    n = N;
    for(int i=0; i<N-1; i++) link[A[i]].push_back(B[i]), link[B[i]].push_back(A[i]);
    locCnt = n;
    dfs(0);
    for(int i=0; i<N-1; i++){
        if(depth[A[i]] > depth[B[i]]) low[i] = A[i];
        else low[i] = B[i];
        edge[low[i]] = i;
    }
}

int Boris(int x){
    int sum = 0;
    while(!mark[x]){
        if(Ask(edge[x])) sum++;
        x = p[x];
    }
    int base = numLoc[x];
    for(int i=0; i<9; i++){
        if(Ask(base+i)) sum += (1<<i);
    }
    return sum;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 624 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
4 Correct 7 ms 828 KB Output is correct
5 Correct 6 ms 884 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 5 ms 896 KB Output is correct
8 Correct 5 ms 1004 KB Output is correct
9 Correct 5 ms 900 KB Output is correct
10 Correct 5 ms 916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 896 KB Output is correct
2 Correct 5 ms 900 KB Output is correct
3 Correct 6 ms 960 KB Output is correct
4 Correct 6 ms 1008 KB Output is correct
5 Correct 7 ms 1088 KB Output is correct
6 Correct 6 ms 1080 KB Output is correct
7 Correct 8 ms 1192 KB Output is correct
8 Correct 6 ms 1016 KB Output is correct
9 Correct 6 ms 1092 KB Output is correct
10 Correct 6 ms 1084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1176 KB Output is correct
2 Correct 15 ms 1556 KB Output is correct
3 Correct 15 ms 1684 KB Output is correct
4 Correct 13 ms 1700 KB Output is correct
5 Correct 13 ms 1712 KB Output is correct
6 Correct 15 ms 1672 KB Output is correct
7 Correct 13 ms 1692 KB Output is correct
8 Correct 14 ms 1832 KB Output is correct
9 Correct 13 ms 1664 KB Output is correct
10 Correct 13 ms 1640 KB Output is correct
11 Correct 16 ms 1672 KB Output is correct
12 Correct 12 ms 1624 KB Output is correct
13 Correct 13 ms 1672 KB Output is correct
14 Correct 12 ms 1668 KB Output is correct
15 Correct 16 ms 1716 KB Output is correct
16 Correct 15 ms 1672 KB Output is correct
17 Correct 13 ms 1704 KB Output is correct
18 Correct 13 ms 1716 KB Output is correct
19 Correct 13 ms 1716 KB Output is correct
20 Correct 12 ms 1580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1064 KB Output is correct
2 Correct 12 ms 1644 KB Output is correct
3 Correct 11 ms 1644 KB Output is correct
4 Correct 12 ms 1664 KB Output is correct
5 Correct 13 ms 1620 KB Output is correct
6 Correct 11 ms 1596 KB Output is correct
7 Correct 13 ms 1668 KB Output is correct
8 Correct 13 ms 1620 KB Output is correct
9 Correct 13 ms 1688 KB Output is correct
10 Correct 11 ms 1692 KB Output is correct
11 Correct 12 ms 1600 KB Output is correct
12 Correct 12 ms 1476 KB Output is correct
13 Correct 13 ms 1564 KB Output is correct
14 Correct 13 ms 1664 KB Output is correct
15 Correct 13 ms 1668 KB Output is correct
16 Correct 13 ms 1464 KB Output is correct
17 Correct 13 ms 1696 KB Output is correct
18 Correct 12 ms 1644 KB Output is correct
19 Correct 15 ms 1712 KB Output is correct
20 Correct 12 ms 1568 KB Output is correct
21 Correct 13 ms 1688 KB Output is correct
22 Correct 13 ms 1712 KB Output is correct
23 Correct 15 ms 1684 KB Output is correct
24 Correct 16 ms 1612 KB Output is correct
25 Correct 12 ms 1680 KB Output is correct
26 Correct 13 ms 1688 KB Output is correct
27 Correct 12 ms 1608 KB Output is correct
28 Correct 13 ms 1672 KB Output is correct
29 Correct 12 ms 1632 KB Output is correct
30 Correct 12 ms 1672 KB Output is correct
31 Correct 15 ms 1664 KB Output is correct
32 Correct 13 ms 1488 KB Output is correct
33 Correct 13 ms 1688 KB Output is correct
34 Correct 13 ms 1604 KB Output is correct
35 Correct 12 ms 1572 KB Output is correct
36 Correct 13 ms 1696 KB Output is correct
37 Correct 11 ms 1524 KB Output is correct
38 Correct 13 ms 1648 KB Output is correct
39 Correct 13 ms 1692 KB Output is correct
40 Correct 12 ms 1656 KB Output is correct
41 Correct 11 ms 1560 KB Output is correct
42 Correct 13 ms 1616 KB Output is correct
43 Correct 11 ms 1580 KB Output is correct
44 Correct 11 ms 1692 KB Output is correct
45 Correct 12 ms 1664 KB Output is correct
46 Correct 12 ms 1652 KB Output is correct
47 Correct 13 ms 1692 KB Output is correct
48 Correct 12 ms 1672 KB Output is correct
49 Correct 11 ms 1692 KB Output is correct
50 Correct 13 ms 1676 KB Output is correct