Submission #953482

# Submission time Handle Problem Language Result Execution time Memory
953482 2024-03-26T03:12:51 Z tnknguyen_ Vinjete (COI22_vinjete) C++14
56 / 100
152 ms 90960 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n' 
#define pii pair<int, int>

const int MX = 1e5 + 5;
vector<pair<int, pii>> gr[MX];
int L[MX], R[MX], f[MX];
int ans[MX];

struct node{
    int good, sum;
    node(){
        good = sum = 0;
    }
};

struct SMT{ 
    vector<node> tree;
    int n = 1e6 + 5;

    SMT(){
        tree.assign(4*n + 5, node());
    };

    void update(int id, int l, int r, int u, int v, int val){
        if(r < u || l > v){
            return;
        }
        if(u <= l && r <= v){
            tree[id].good += val;
            tree[id].sum = (tree[id].good ? r-l+1 : tree[2*id].sum + tree[2*id+1].sum);
            return;
        }
        int mid = (l + r) >> 1, ID = (id << 1);
        update(ID, l, mid, u, v, val);
        update(ID|1, mid+1, r, u, v, val);

        tree[id].sum = (tree[id].good ? r-l+1 : tree[ID].sum + tree[ID|1].sum);
    }

    void update(int l, int r, int val){
        update(1, 1, n, l, r, val);
    }

    int get(int id, int l, int r, int u, int v){
        if(r < u || l > v){
            return 0;
        }
        if(u <= l && r <= v){
            return tree[id].sum;
        }
        int mid = (l + r) >> 1, ID = (id << 1);
        return get(ID, l, mid, u, v) + get(ID|1, mid+1, r, u, v);
    }
};
SMT smt;

void dfs(int u, int p){
    ans[u] = smt.tree[1].sum;
    for(pair<int, pii> e : gr[u]){
        int v, l, r;
        v = e.first;
        tie(l, r) = e.second;
        if(v != p){
            smt.update(l, r, 1);
            dfs(v, u);
            smt.update(l, r, -1);
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);

    int n, m;
    cin>>n>>m;

    for(int i=1; i<n; ++i){
        int u, v, l, r;
        cin>>u>>v>>l>>r;
        gr[u].push_back({v, {l, r}});
        gr[v].push_back({u, {l, r}});
    }

    dfs(1, 0);

    for(int i=2; i<=n; ++i){
        cout<<ans[i]<<endl;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 29 ms 66388 KB Output is correct
2 Correct 11 ms 66396 KB Output is correct
3 Correct 13 ms 66392 KB Output is correct
4 Correct 13 ms 66392 KB Output is correct
5 Correct 12 ms 66404 KB Output is correct
6 Correct 12 ms 66512 KB Output is correct
7 Correct 12 ms 66140 KB Output is correct
8 Correct 15 ms 66384 KB Output is correct
9 Correct 12 ms 66396 KB Output is correct
10 Correct 12 ms 66396 KB Output is correct
11 Correct 12 ms 66368 KB Output is correct
12 Correct 13 ms 66220 KB Output is correct
13 Correct 13 ms 66280 KB Output is correct
14 Correct 14 ms 66396 KB Output is correct
15 Correct 11 ms 66140 KB Output is correct
16 Correct 10 ms 66140 KB Output is correct
17 Correct 12 ms 66396 KB Output is correct
18 Correct 12 ms 66392 KB Output is correct
19 Correct 14 ms 66372 KB Output is correct
20 Correct 12 ms 66396 KB Output is correct
21 Correct 11 ms 66324 KB Output is correct
22 Correct 12 ms 66396 KB Output is correct
23 Correct 11 ms 66120 KB Output is correct
24 Correct 11 ms 66140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 66388 KB Output is correct
2 Correct 11 ms 66396 KB Output is correct
3 Correct 13 ms 66392 KB Output is correct
4 Correct 13 ms 66392 KB Output is correct
5 Correct 12 ms 66404 KB Output is correct
6 Correct 12 ms 66512 KB Output is correct
7 Correct 12 ms 66140 KB Output is correct
8 Correct 15 ms 66384 KB Output is correct
9 Correct 12 ms 66396 KB Output is correct
10 Correct 12 ms 66396 KB Output is correct
11 Correct 12 ms 66368 KB Output is correct
12 Correct 13 ms 66220 KB Output is correct
13 Correct 13 ms 66280 KB Output is correct
14 Correct 14 ms 66396 KB Output is correct
15 Correct 11 ms 66140 KB Output is correct
16 Correct 10 ms 66140 KB Output is correct
17 Correct 12 ms 66396 KB Output is correct
18 Correct 12 ms 66392 KB Output is correct
19 Correct 14 ms 66372 KB Output is correct
20 Correct 12 ms 66396 KB Output is correct
21 Correct 11 ms 66324 KB Output is correct
22 Correct 12 ms 66396 KB Output is correct
23 Correct 11 ms 66120 KB Output is correct
24 Correct 11 ms 66140 KB Output is correct
25 Incorrect 11 ms 66396 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 66388 KB Output is correct
2 Correct 11 ms 66396 KB Output is correct
3 Correct 13 ms 66392 KB Output is correct
4 Correct 13 ms 66392 KB Output is correct
5 Correct 12 ms 66404 KB Output is correct
6 Correct 12 ms 66512 KB Output is correct
7 Correct 12 ms 66140 KB Output is correct
8 Correct 15 ms 66384 KB Output is correct
9 Correct 12 ms 66396 KB Output is correct
10 Correct 12 ms 66396 KB Output is correct
11 Correct 12 ms 66368 KB Output is correct
12 Correct 13 ms 66220 KB Output is correct
13 Correct 13 ms 66280 KB Output is correct
14 Correct 14 ms 66396 KB Output is correct
15 Correct 11 ms 66140 KB Output is correct
16 Correct 10 ms 66140 KB Output is correct
17 Correct 12 ms 66396 KB Output is correct
18 Correct 12 ms 66392 KB Output is correct
19 Correct 14 ms 66372 KB Output is correct
20 Correct 12 ms 66396 KB Output is correct
21 Correct 11 ms 66324 KB Output is correct
22 Correct 12 ms 66396 KB Output is correct
23 Correct 11 ms 66120 KB Output is correct
24 Correct 11 ms 66140 KB Output is correct
25 Correct 46 ms 76884 KB Output is correct
26 Correct 47 ms 76700 KB Output is correct
27 Correct 55 ms 76880 KB Output is correct
28 Correct 57 ms 76792 KB Output is correct
29 Correct 43 ms 76884 KB Output is correct
30 Correct 43 ms 76692 KB Output is correct
31 Correct 15 ms 67416 KB Output is correct
32 Correct 14 ms 67420 KB Output is correct
33 Correct 18 ms 67456 KB Output is correct
34 Correct 15 ms 67420 KB Output is correct
35 Correct 45 ms 71764 KB Output is correct
36 Correct 45 ms 71964 KB Output is correct
37 Correct 55 ms 71680 KB Output is correct
38 Correct 63 ms 72220 KB Output is correct
39 Correct 42 ms 71828 KB Output is correct
40 Correct 42 ms 71764 KB Output is correct
41 Correct 15 ms 66648 KB Output is correct
42 Correct 15 ms 66652 KB Output is correct
43 Correct 47 ms 71312 KB Output is correct
44 Correct 46 ms 71160 KB Output is correct
45 Correct 56 ms 71248 KB Output is correct
46 Correct 56 ms 71252 KB Output is correct
47 Correct 45 ms 71248 KB Output is correct
48 Correct 45 ms 71176 KB Output is correct
49 Correct 16 ms 66648 KB Output is correct
50 Correct 19 ms 66652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 66388 KB Output is correct
2 Correct 11 ms 66396 KB Output is correct
3 Correct 13 ms 66392 KB Output is correct
4 Correct 13 ms 66392 KB Output is correct
5 Correct 12 ms 66404 KB Output is correct
6 Correct 12 ms 66512 KB Output is correct
7 Correct 12 ms 66140 KB Output is correct
8 Correct 15 ms 66384 KB Output is correct
9 Correct 12 ms 66396 KB Output is correct
10 Correct 12 ms 66396 KB Output is correct
11 Correct 12 ms 66368 KB Output is correct
12 Correct 13 ms 66220 KB Output is correct
13 Correct 13 ms 66280 KB Output is correct
14 Correct 14 ms 66396 KB Output is correct
15 Correct 11 ms 66140 KB Output is correct
16 Correct 10 ms 66140 KB Output is correct
17 Correct 12 ms 66396 KB Output is correct
18 Correct 12 ms 66392 KB Output is correct
19 Correct 14 ms 66372 KB Output is correct
20 Correct 12 ms 66396 KB Output is correct
21 Correct 11 ms 66324 KB Output is correct
22 Correct 12 ms 66396 KB Output is correct
23 Correct 11 ms 66120 KB Output is correct
24 Correct 11 ms 66140 KB Output is correct
25 Correct 46 ms 76884 KB Output is correct
26 Correct 47 ms 76700 KB Output is correct
27 Correct 55 ms 76880 KB Output is correct
28 Correct 57 ms 76792 KB Output is correct
29 Correct 43 ms 76884 KB Output is correct
30 Correct 43 ms 76692 KB Output is correct
31 Correct 15 ms 67416 KB Output is correct
32 Correct 14 ms 67420 KB Output is correct
33 Correct 18 ms 67456 KB Output is correct
34 Correct 15 ms 67420 KB Output is correct
35 Correct 45 ms 71764 KB Output is correct
36 Correct 45 ms 71964 KB Output is correct
37 Correct 55 ms 71680 KB Output is correct
38 Correct 63 ms 72220 KB Output is correct
39 Correct 42 ms 71828 KB Output is correct
40 Correct 42 ms 71764 KB Output is correct
41 Correct 15 ms 66648 KB Output is correct
42 Correct 15 ms 66652 KB Output is correct
43 Correct 47 ms 71312 KB Output is correct
44 Correct 46 ms 71160 KB Output is correct
45 Correct 56 ms 71248 KB Output is correct
46 Correct 56 ms 71252 KB Output is correct
47 Correct 45 ms 71248 KB Output is correct
48 Correct 45 ms 71176 KB Output is correct
49 Correct 16 ms 66648 KB Output is correct
50 Correct 19 ms 66652 KB Output is correct
51 Correct 96 ms 89424 KB Output is correct
52 Correct 110 ms 90772 KB Output is correct
53 Correct 127 ms 90960 KB Output is correct
54 Correct 126 ms 90916 KB Output is correct
55 Correct 108 ms 90564 KB Output is correct
56 Correct 95 ms 90824 KB Output is correct
57 Correct 25 ms 71000 KB Output is correct
58 Correct 25 ms 71072 KB Output is correct
59 Correct 26 ms 71320 KB Output is correct
60 Correct 26 ms 71004 KB Output is correct
61 Correct 101 ms 78552 KB Output is correct
62 Correct 104 ms 79004 KB Output is correct
63 Correct 152 ms 78416 KB Output is correct
64 Correct 142 ms 78632 KB Output is correct
65 Correct 105 ms 78528 KB Output is correct
66 Correct 96 ms 78136 KB Output is correct
67 Correct 27 ms 68560 KB Output is correct
68 Correct 28 ms 68444 KB Output is correct
69 Correct 124 ms 77116 KB Output is correct
70 Correct 105 ms 76768 KB Output is correct
71 Correct 145 ms 77140 KB Output is correct
72 Correct 141 ms 77124 KB Output is correct
73 Correct 100 ms 76504 KB Output is correct
74 Correct 107 ms 76624 KB Output is correct
75 Correct 30 ms 68252 KB Output is correct
76 Correct 28 ms 68248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 66388 KB Output is correct
2 Correct 11 ms 66396 KB Output is correct
3 Correct 13 ms 66392 KB Output is correct
4 Correct 13 ms 66392 KB Output is correct
5 Correct 12 ms 66404 KB Output is correct
6 Correct 12 ms 66512 KB Output is correct
7 Correct 12 ms 66140 KB Output is correct
8 Correct 15 ms 66384 KB Output is correct
9 Correct 12 ms 66396 KB Output is correct
10 Correct 12 ms 66396 KB Output is correct
11 Correct 12 ms 66368 KB Output is correct
12 Correct 13 ms 66220 KB Output is correct
13 Correct 13 ms 66280 KB Output is correct
14 Correct 14 ms 66396 KB Output is correct
15 Correct 11 ms 66140 KB Output is correct
16 Correct 10 ms 66140 KB Output is correct
17 Correct 12 ms 66396 KB Output is correct
18 Correct 12 ms 66392 KB Output is correct
19 Correct 14 ms 66372 KB Output is correct
20 Correct 12 ms 66396 KB Output is correct
21 Correct 11 ms 66324 KB Output is correct
22 Correct 12 ms 66396 KB Output is correct
23 Correct 11 ms 66120 KB Output is correct
24 Correct 11 ms 66140 KB Output is correct
25 Incorrect 11 ms 66396 KB Output isn't correct
26 Halted 0 ms 0 KB -