Submission #990629

# Submission time Handle Problem Language Result Execution time Memory
990629 2024-05-30T18:54:33 Z alexdd Vinjete (COI22_vinjete) C++17
100 / 100
395 ms 182680 KB
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<pair<int,pair<int,int>>> con[100005];
pair<int,int> combine(pair<int,int> x, pair<int,int> y)
{
    if(x.first < y.first)
        return x;
    if(x.first > y.first)
        return y;
    return {x.first,x.second+y.second};
}
struct node
{
    pair<int,int> mnm;
    int lazy,tole,tori;
};
node emp = {{0,0},0,0,0};
vector<node> aint;
void baga(int nod, int val)
{
    aint[nod].lazy+=val;
    aint[nod].mnm.first+=val;
}
void propagate(int nod)
{
    if(!aint[nod].lazy)
        return;
    baga(aint[nod].tole,aint[nod].lazy);
    baga(aint[nod].tori,aint[nod].lazy);
    aint[nod].lazy=0;
}
void upd(int nod, int st, int dr, int le, int ri, int newv)
{
    if(le>ri)
        return;
    if(le==st && dr==ri)
    {
        baga(nod,newv);
        return;
    }
    int mij=(st+dr)/2;
    if(aint[nod].tole==0)
    {
        aint[nod].tole = aint.size();
        aint.push_back({{0,mij-st+1},0,0,0});
    }
    if(aint[nod].tori==0)
    {
        aint[nod].tori = aint.size();
        aint.push_back({{0,dr-mij},0,0,0});
    }
    propagate(nod);
    upd(aint[nod].tole,st,mij,le,min(mij,ri),newv);
    upd(aint[nod].tori,mij+1,dr,max(mij+1,le),ri,newv);
    aint[nod].mnm = combine(aint[aint[nod].tole].mnm, aint[aint[nod].tori].mnm);
}
int rez[100005];
void dfs(int nod, int par, pair<int,int> r)
{
    upd(0,1,m,r.first,r.second,1);
    if(aint[0].mnm.first==0) rez[nod] = m - aint[0].mnm.second;
    else rez[nod] = m;
    for(auto x:con[nod])
    {
        if(x.first!=par)
        {
            dfs(x.first,nod,x.second);
        }
    }
    upd(0,1,m,r.first,r.second,-1);
}
signed main()
{
    cin>>n>>m;
    int u,v,a,b;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v>>a>>b;
        con[u].push_back({v,{a,b}});
        con[v].push_back({u,{a,b}});
    }
    aint.push_back({{0,m},0,0,0});
    dfs(1,0,{1,0});
    for(int i=2;i<=n;i++)
        cout<<rez[i]<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2908 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 3192 KB Output is correct
4 Correct 2 ms 3032 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2904 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 2 ms 2908 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 2 ms 3152 KB Output is correct
15 Correct 1 ms 2908 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 2 ms 2908 KB Output is correct
18 Correct 2 ms 2908 KB Output is correct
19 Correct 2 ms 2908 KB Output is correct
20 Correct 2 ms 2908 KB Output is correct
21 Correct 2 ms 2908 KB Output is correct
22 Correct 2 ms 2908 KB Output is correct
23 Correct 1 ms 2908 KB Output is correct
24 Correct 1 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2908 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 3192 KB Output is correct
4 Correct 2 ms 3032 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2904 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 2 ms 2908 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 2 ms 3152 KB Output is correct
15 Correct 1 ms 2908 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 2 ms 2908 KB Output is correct
18 Correct 2 ms 2908 KB Output is correct
19 Correct 2 ms 2908 KB Output is correct
20 Correct 2 ms 2908 KB Output is correct
21 Correct 2 ms 2908 KB Output is correct
22 Correct 2 ms 2908 KB Output is correct
23 Correct 1 ms 2908 KB Output is correct
24 Correct 1 ms 2908 KB Output is correct
25 Correct 3 ms 3160 KB Output is correct
26 Correct 3 ms 2908 KB Output is correct
27 Correct 6 ms 6748 KB Output is correct
28 Correct 5 ms 5664 KB Output is correct
29 Correct 3 ms 4320 KB Output is correct
30 Correct 3 ms 4436 KB Output is correct
31 Correct 5 ms 6864 KB Output is correct
32 Correct 5 ms 5840 KB Output is correct
33 Correct 5 ms 5840 KB Output is correct
34 Correct 5 ms 5840 KB Output is correct
35 Correct 3 ms 2908 KB Output is correct
36 Correct 3 ms 2908 KB Output is correct
37 Correct 5 ms 5580 KB Output is correct
38 Correct 5 ms 6608 KB Output is correct
39 Correct 3 ms 4432 KB Output is correct
40 Correct 3 ms 4436 KB Output is correct
41 Correct 4 ms 6608 KB Output is correct
42 Correct 5 ms 5952 KB Output is correct
43 Correct 3 ms 2908 KB Output is correct
44 Correct 3 ms 2908 KB Output is correct
45 Correct 5 ms 5588 KB Output is correct
46 Correct 5 ms 5584 KB Output is correct
47 Correct 4 ms 4436 KB Output is correct
48 Correct 3 ms 4324 KB Output is correct
49 Correct 5 ms 5584 KB Output is correct
50 Correct 5 ms 5584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2908 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 3192 KB Output is correct
4 Correct 2 ms 3032 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2904 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 2 ms 2908 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 2 ms 3152 KB Output is correct
15 Correct 1 ms 2908 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 2 ms 2908 KB Output is correct
18 Correct 2 ms 2908 KB Output is correct
19 Correct 2 ms 2908 KB Output is correct
20 Correct 2 ms 2908 KB Output is correct
21 Correct 2 ms 2908 KB Output is correct
22 Correct 2 ms 2908 KB Output is correct
23 Correct 1 ms 2908 KB Output is correct
24 Correct 1 ms 2908 KB Output is correct
25 Correct 56 ms 8536 KB Output is correct
26 Correct 56 ms 8536 KB Output is correct
27 Correct 70 ms 10776 KB Output is correct
28 Correct 69 ms 10916 KB Output is correct
29 Correct 50 ms 10184 KB Output is correct
30 Correct 50 ms 10176 KB Output is correct
31 Correct 7 ms 4948 KB Output is correct
32 Correct 7 ms 4948 KB Output is correct
33 Correct 7 ms 4804 KB Output is correct
34 Correct 8 ms 4948 KB Output is correct
35 Correct 57 ms 5844 KB Output is correct
36 Correct 58 ms 6200 KB Output is correct
37 Correct 69 ms 8648 KB Output is correct
38 Correct 69 ms 8648 KB Output is correct
39 Correct 50 ms 8392 KB Output is correct
40 Correct 51 ms 8396 KB Output is correct
41 Correct 8 ms 4672 KB Output is correct
42 Correct 10 ms 4780 KB Output is correct
43 Correct 56 ms 5716 KB Output is correct
44 Correct 67 ms 5712 KB Output is correct
45 Correct 69 ms 8392 KB Output is correct
46 Correct 72 ms 8388 KB Output is correct
47 Correct 53 ms 8432 KB Output is correct
48 Correct 53 ms 9408 KB Output is correct
49 Correct 8 ms 4692 KB Output is correct
50 Correct 7 ms 4692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2908 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 3192 KB Output is correct
4 Correct 2 ms 3032 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2904 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 2 ms 2908 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 2 ms 3152 KB Output is correct
15 Correct 1 ms 2908 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 2 ms 2908 KB Output is correct
18 Correct 2 ms 2908 KB Output is correct
19 Correct 2 ms 2908 KB Output is correct
20 Correct 2 ms 2908 KB Output is correct
21 Correct 2 ms 2908 KB Output is correct
22 Correct 2 ms 2908 KB Output is correct
23 Correct 1 ms 2908 KB Output is correct
24 Correct 1 ms 2908 KB Output is correct
25 Correct 56 ms 8536 KB Output is correct
26 Correct 56 ms 8536 KB Output is correct
27 Correct 70 ms 10776 KB Output is correct
28 Correct 69 ms 10916 KB Output is correct
29 Correct 50 ms 10184 KB Output is correct
30 Correct 50 ms 10176 KB Output is correct
31 Correct 7 ms 4948 KB Output is correct
32 Correct 7 ms 4948 KB Output is correct
33 Correct 7 ms 4804 KB Output is correct
34 Correct 8 ms 4948 KB Output is correct
35 Correct 57 ms 5844 KB Output is correct
36 Correct 58 ms 6200 KB Output is correct
37 Correct 69 ms 8648 KB Output is correct
38 Correct 69 ms 8648 KB Output is correct
39 Correct 50 ms 8392 KB Output is correct
40 Correct 51 ms 8396 KB Output is correct
41 Correct 8 ms 4672 KB Output is correct
42 Correct 10 ms 4780 KB Output is correct
43 Correct 56 ms 5716 KB Output is correct
44 Correct 67 ms 5712 KB Output is correct
45 Correct 69 ms 8392 KB Output is correct
46 Correct 72 ms 8388 KB Output is correct
47 Correct 53 ms 8432 KB Output is correct
48 Correct 53 ms 9408 KB Output is correct
49 Correct 8 ms 4692 KB Output is correct
50 Correct 7 ms 4692 KB Output is correct
51 Correct 143 ms 16720 KB Output is correct
52 Correct 141 ms 16720 KB Output is correct
53 Correct 181 ms 20664 KB Output is correct
54 Correct 183 ms 22204 KB Output is correct
55 Correct 130 ms 21436 KB Output is correct
56 Correct 131 ms 20668 KB Output is correct
57 Correct 26 ms 8344 KB Output is correct
58 Correct 26 ms 8400 KB Output is correct
59 Correct 26 ms 8404 KB Output is correct
60 Correct 27 ms 8376 KB Output is correct
61 Correct 142 ms 10832 KB Output is correct
62 Correct 141 ms 10984 KB Output is correct
63 Correct 181 ms 17092 KB Output is correct
64 Correct 175 ms 15812 KB Output is correct
65 Correct 128 ms 17088 KB Output is correct
66 Correct 128 ms 16160 KB Output is correct
67 Correct 26 ms 7120 KB Output is correct
68 Correct 26 ms 7888 KB Output is correct
69 Correct 144 ms 9812 KB Output is correct
70 Correct 144 ms 9812 KB Output is correct
71 Correct 177 ms 16064 KB Output is correct
72 Correct 175 ms 15552 KB Output is correct
73 Correct 137 ms 15972 KB Output is correct
74 Correct 127 ms 16020 KB Output is correct
75 Correct 28 ms 6856 KB Output is correct
76 Correct 28 ms 6864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2908 KB Output is correct
2 Correct 2 ms 2908 KB Output is correct
3 Correct 2 ms 3192 KB Output is correct
4 Correct 2 ms 3032 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2904 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 2 ms 2908 KB Output is correct
12 Correct 2 ms 2908 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 2 ms 3152 KB Output is correct
15 Correct 1 ms 2908 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 2 ms 2908 KB Output is correct
18 Correct 2 ms 2908 KB Output is correct
19 Correct 2 ms 2908 KB Output is correct
20 Correct 2 ms 2908 KB Output is correct
21 Correct 2 ms 2908 KB Output is correct
22 Correct 2 ms 2908 KB Output is correct
23 Correct 1 ms 2908 KB Output is correct
24 Correct 1 ms 2908 KB Output is correct
25 Correct 3 ms 3160 KB Output is correct
26 Correct 3 ms 2908 KB Output is correct
27 Correct 6 ms 6748 KB Output is correct
28 Correct 5 ms 5664 KB Output is correct
29 Correct 3 ms 4320 KB Output is correct
30 Correct 3 ms 4436 KB Output is correct
31 Correct 5 ms 6864 KB Output is correct
32 Correct 5 ms 5840 KB Output is correct
33 Correct 5 ms 5840 KB Output is correct
34 Correct 5 ms 5840 KB Output is correct
35 Correct 3 ms 2908 KB Output is correct
36 Correct 3 ms 2908 KB Output is correct
37 Correct 5 ms 5580 KB Output is correct
38 Correct 5 ms 6608 KB Output is correct
39 Correct 3 ms 4432 KB Output is correct
40 Correct 3 ms 4436 KB Output is correct
41 Correct 4 ms 6608 KB Output is correct
42 Correct 5 ms 5952 KB Output is correct
43 Correct 3 ms 2908 KB Output is correct
44 Correct 3 ms 2908 KB Output is correct
45 Correct 5 ms 5588 KB Output is correct
46 Correct 5 ms 5584 KB Output is correct
47 Correct 4 ms 4436 KB Output is correct
48 Correct 3 ms 4324 KB Output is correct
49 Correct 5 ms 5584 KB Output is correct
50 Correct 5 ms 5584 KB Output is correct
51 Correct 56 ms 8536 KB Output is correct
52 Correct 56 ms 8536 KB Output is correct
53 Correct 70 ms 10776 KB Output is correct
54 Correct 69 ms 10916 KB Output is correct
55 Correct 50 ms 10184 KB Output is correct
56 Correct 50 ms 10176 KB Output is correct
57 Correct 7 ms 4948 KB Output is correct
58 Correct 7 ms 4948 KB Output is correct
59 Correct 7 ms 4804 KB Output is correct
60 Correct 8 ms 4948 KB Output is correct
61 Correct 57 ms 5844 KB Output is correct
62 Correct 58 ms 6200 KB Output is correct
63 Correct 69 ms 8648 KB Output is correct
64 Correct 69 ms 8648 KB Output is correct
65 Correct 50 ms 8392 KB Output is correct
66 Correct 51 ms 8396 KB Output is correct
67 Correct 8 ms 4672 KB Output is correct
68 Correct 10 ms 4780 KB Output is correct
69 Correct 56 ms 5716 KB Output is correct
70 Correct 67 ms 5712 KB Output is correct
71 Correct 69 ms 8392 KB Output is correct
72 Correct 72 ms 8388 KB Output is correct
73 Correct 53 ms 8432 KB Output is correct
74 Correct 53 ms 9408 KB Output is correct
75 Correct 8 ms 4692 KB Output is correct
76 Correct 7 ms 4692 KB Output is correct
77 Correct 143 ms 16720 KB Output is correct
78 Correct 141 ms 16720 KB Output is correct
79 Correct 181 ms 20664 KB Output is correct
80 Correct 183 ms 22204 KB Output is correct
81 Correct 130 ms 21436 KB Output is correct
82 Correct 131 ms 20668 KB Output is correct
83 Correct 26 ms 8344 KB Output is correct
84 Correct 26 ms 8400 KB Output is correct
85 Correct 26 ms 8404 KB Output is correct
86 Correct 27 ms 8376 KB Output is correct
87 Correct 142 ms 10832 KB Output is correct
88 Correct 141 ms 10984 KB Output is correct
89 Correct 181 ms 17092 KB Output is correct
90 Correct 175 ms 15812 KB Output is correct
91 Correct 128 ms 17088 KB Output is correct
92 Correct 128 ms 16160 KB Output is correct
93 Correct 26 ms 7120 KB Output is correct
94 Correct 26 ms 7888 KB Output is correct
95 Correct 144 ms 9812 KB Output is correct
96 Correct 144 ms 9812 KB Output is correct
97 Correct 177 ms 16064 KB Output is correct
98 Correct 175 ms 15552 KB Output is correct
99 Correct 137 ms 15972 KB Output is correct
100 Correct 127 ms 16020 KB Output is correct
101 Correct 28 ms 6856 KB Output is correct
102 Correct 28 ms 6864 KB Output is correct
103 Correct 207 ms 17488 KB Output is correct
104 Correct 214 ms 17488 KB Output is correct
105 Correct 395 ms 182680 KB Output is correct
106 Correct 391 ms 181140 KB Output is correct
107 Correct 235 ms 98216 KB Output is correct
108 Correct 238 ms 97904 KB Output is correct
109 Correct 58 ms 48316 KB Output is correct
110 Correct 59 ms 48564 KB Output is correct
111 Correct 59 ms 47796 KB Output is correct
112 Correct 62 ms 47548 KB Output is correct
113 Correct 219 ms 11968 KB Output is correct
114 Correct 213 ms 11604 KB Output is correct
115 Correct 368 ms 177044 KB Output is correct
116 Correct 385 ms 177412 KB Output is correct
117 Correct 241 ms 93456 KB Output is correct
118 Correct 219 ms 94364 KB Output is correct
119 Correct 58 ms 47532 KB Output is correct
120 Correct 57 ms 46500 KB Output is correct
121 Correct 204 ms 10836 KB Output is correct
122 Correct 207 ms 10836 KB Output is correct
123 Correct 379 ms 176532 KB Output is correct
124 Correct 373 ms 175876 KB Output is correct
125 Correct 234 ms 93596 KB Output is correct
126 Correct 231 ms 93852 KB Output is correct
127 Correct 59 ms 46252 KB Output is correct
128 Correct 62 ms 47536 KB Output is correct