Submission #925329

# Submission time Handle Problem Language Result Execution time Memory
925329 2024-02-11T12:37:34 Z bachhoangxuan None (JOI16_snowy) C++17
100 / 100
14 ms 2500 KB
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second

namespace{
    const int maxn = 505;
    int n;
    vector<int> ver;
    vector<pii> edge[maxn];
    int dep[maxn],pid[maxn],ind[maxn],cnt[maxn],par[maxn];
}

void InitAnya(int N, int A[] , int B[]) {
    n=N;ver.clear();
    for(int i=0;i<N;i++) edge[i].clear();
    for(int i=0;i<N-1;i++){
        edge[A[i]].push_back({B[i],i});
        edge[B[i]].push_back({A[i],i});
    }
    function<int(int,int)> dfs = [&](int u,int p){
        for(auto [v,id]:edge[u]) if(v!=p){
            pid[v]=id;par[v]=u;
            dep[u]=max(dep[u],(dfs(v,u)+1)%10);
        }
        //cout << u << ' ' << dep[u] << ' ' << par[u] << ' ' << pid[u] << '\n';
        if(dep[u]==9){
            ind[u]=(int)ver.size();
            ver.push_back(u);
        }
        return dep[u];
    };
    par[0]=-1;
    dfs(0,-1);
}

void Anya(int C[]) {
    cnt[0]=0;
    for(int i=1;i<n;i++) Save(i,C[pid[i]]);
    function<void(int,int)> dfs = [&](int u,int p){
        for(auto [v,id]:edge[u]) if(v!=p){
            cnt[v]=cnt[u]+C[id];
            dfs(v,u);
        }
    };
    dfs(0,0);
    for(int i=0;i<(int)ver.size();i++){
        for(int j=0;j<9;j++) Save(n+9*i+j,cnt[ver[i]]>>j&1);
    }
}
#include "Borislib.h"
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second

namespace{
    const int maxn = 505;
    int n;
    vector<int> ver;
    vector<pii> edge[maxn];
    int dep[maxn],pid[maxn],ind[maxn],par[maxn];
}

void InitBoris(int N, int A[] , int B[]) {
    n=N;ver.clear();
    for(int i=0;i<N;i++) edge[i].clear();
    for(int i=0;i<N-1;i++){
        edge[A[i]].push_back({B[i],i});
        edge[B[i]].push_back({A[i],i});
    }
    function<int(int,int)> dfs = [&](int u,int p){
        for(auto [v,id]:edge[u]) if(v!=p){
            pid[v]=id;par[v]=u;
            dep[u]=max(dep[u],(dfs(v,u)+1)%10);
        }
        if(dep[u]==9){
            ind[u]=(int)ver.size();
            ver.push_back(u);
        }
        return dep[u];
    };
    par[0]=-1;
    dfs(0,-1);
}

int Boris(int u){
    int cnt=0;
    while(u!=-1 && dep[u]!=9){
        cnt+=Ask(u);
        u=par[u];
    }
    if(u!=-1){
        int x=ind[u];
        for(int i=0;i<9;i++) cnt+=Ask(n+9*x+i)<<i;
    }
    return cnt;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 804 KB Output is correct
2 Correct 1 ms 804 KB Output is correct
3 Correct 2 ms 848 KB Output is correct
4 Correct 3 ms 1132 KB Output is correct
5 Correct 5 ms 1372 KB Output is correct
6 Correct 5 ms 1212 KB Output is correct
7 Correct 5 ms 1204 KB Output is correct
8 Correct 5 ms 1204 KB Output is correct
9 Correct 5 ms 1212 KB Output is correct
10 Correct 5 ms 1204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1236 KB Output is correct
2 Correct 7 ms 1240 KB Output is correct
3 Correct 6 ms 1244 KB Output is correct
4 Correct 6 ms 1256 KB Output is correct
5 Correct 6 ms 1248 KB Output is correct
6 Correct 6 ms 1256 KB Output is correct
7 Correct 6 ms 1248 KB Output is correct
8 Correct 6 ms 1244 KB Output is correct
9 Correct 6 ms 1252 KB Output is correct
10 Correct 6 ms 1256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1736 KB Output is correct
2 Correct 11 ms 1740 KB Output is correct
3 Correct 12 ms 1896 KB Output is correct
4 Correct 11 ms 1736 KB Output is correct
5 Correct 11 ms 1908 KB Output is correct
6 Correct 11 ms 1728 KB Output is correct
7 Correct 11 ms 1720 KB Output is correct
8 Correct 11 ms 1728 KB Output is correct
9 Correct 11 ms 1736 KB Output is correct
10 Correct 11 ms 1704 KB Output is correct
11 Correct 11 ms 1724 KB Output is correct
12 Correct 11 ms 1724 KB Output is correct
13 Correct 11 ms 1728 KB Output is correct
14 Correct 12 ms 1736 KB Output is correct
15 Correct 11 ms 1736 KB Output is correct
16 Correct 11 ms 1732 KB Output is correct
17 Correct 11 ms 1724 KB Output is correct
18 Correct 13 ms 1704 KB Output is correct
19 Correct 11 ms 1736 KB Output is correct
20 Correct 11 ms 1736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1692 KB Output is correct
2 Correct 14 ms 1720 KB Output is correct
3 Correct 10 ms 1720 KB Output is correct
4 Correct 11 ms 1724 KB Output is correct
5 Correct 11 ms 1724 KB Output is correct
6 Correct 10 ms 1716 KB Output is correct
7 Correct 11 ms 1724 KB Output is correct
8 Correct 10 ms 1720 KB Output is correct
9 Correct 11 ms 1728 KB Output is correct
10 Correct 10 ms 1728 KB Output is correct
11 Correct 11 ms 1728 KB Output is correct
12 Correct 11 ms 1720 KB Output is correct
13 Correct 11 ms 1724 KB Output is correct
14 Correct 14 ms 2196 KB Output is correct
15 Correct 13 ms 1712 KB Output is correct
16 Correct 10 ms 1704 KB Output is correct
17 Correct 11 ms 1724 KB Output is correct
18 Correct 11 ms 1732 KB Output is correct
19 Correct 11 ms 1732 KB Output is correct
20 Correct 11 ms 1724 KB Output is correct
21 Correct 11 ms 1732 KB Output is correct
22 Correct 11 ms 1732 KB Output is correct
23 Correct 11 ms 1724 KB Output is correct
24 Correct 11 ms 1736 KB Output is correct
25 Correct 11 ms 1724 KB Output is correct
26 Correct 11 ms 1724 KB Output is correct
27 Correct 11 ms 1812 KB Output is correct
28 Correct 11 ms 1732 KB Output is correct
29 Correct 11 ms 1900 KB Output is correct
30 Correct 11 ms 1724 KB Output is correct
31 Correct 11 ms 2164 KB Output is correct
32 Correct 10 ms 1728 KB Output is correct
33 Correct 11 ms 1712 KB Output is correct
34 Correct 10 ms 1724 KB Output is correct
35 Correct 10 ms 1720 KB Output is correct
36 Correct 11 ms 1732 KB Output is correct
37 Correct 10 ms 1724 KB Output is correct
38 Correct 12 ms 1724 KB Output is correct
39 Correct 11 ms 1724 KB Output is correct
40 Correct 10 ms 1696 KB Output is correct
41 Correct 10 ms 1832 KB Output is correct
42 Correct 10 ms 1720 KB Output is correct
43 Correct 10 ms 1720 KB Output is correct
44 Correct 10 ms 1720 KB Output is correct
45 Correct 10 ms 1676 KB Output is correct
46 Correct 10 ms 1852 KB Output is correct
47 Correct 11 ms 2500 KB Output is correct
48 Correct 10 ms 1728 KB Output is correct
49 Correct 10 ms 1852 KB Output is correct
50 Correct 10 ms 1720 KB Output is correct