Submission #849882

# Submission time Handle Problem Language Result Execution time Memory
849882 2023-09-15T14:02:55 Z 1075508020060209tc Vinjete (COI22_vinjete) C++14
69 / 100
379 ms 138120 KB
#include<bits/stdc++.h>
using namespace std;
//#define int long long
int n;int m;int M;
struct SGTR{
int rl;int rr;
int l;int r;
int mn;
int mnfq;
int lz;
}tr[1000005];
vector<pair<int,int>>e[100005];//{v,eid}
int lar[100005];int rar[100005];
pair<int,int>rmp[2000006];
void pull(int nw){
if(tr[nw*2].mn<tr[nw*2+1].mn){
    tr[nw].mn=tr[nw*2].mn;
    tr[nw].mnfq=tr[nw*2].mnfq;
    return;
}
if(tr[nw*2+1].mn<tr[nw*2].mn){
    tr[nw].mn=tr[nw*2+1].mn;
    tr[nw].mnfq=tr[nw*2+1].mnfq;
    return;
}
tr[nw].mn=tr[nw*2].mn;
tr[nw].mnfq=tr[nw*2].mnfq+tr[nw*2+1].mnfq;
}

void buildtr(int nw,int l,int r){
tr[nw].l=l;tr[nw].r=r;
tr[nw].rl=rmp[l].first;tr[nw].rr=rmp[r].second;
tr[nw].mn=0;
tr[nw].lz=0;
if(l==r){
    tr[nw].mnfq=tr[nw].rr-tr[nw].rl+1;
    return;
}
int mi=(l+r)/2;
buildtr(nw*2,l,mi);buildtr(nw*2+1,mi+1,r);
pull(nw);
}

void psh(int nw){
tr[nw*2].mn+=tr[nw].lz;
tr[nw*2+1].mn+=tr[nw].lz;
tr[nw*2].lz+=tr[nw].lz;
tr[nw*2+1].lz+=tr[nw].lz;
tr[nw].lz=0;
}

void upd(int nw,int rl,int rr,int v){
if(tr[nw].rl>=rl&&tr[nw].rr<=rr){
    tr[nw].lz+=v;
    tr[nw].mn+=v;
   // cout<<"hehe";
    //cout<<nw<<" "<<tr[nw].rl<<" "<<tr[nw].rr<<" "<<tr[nw].mn<<" "<<tr[nw].mnfq<<" "<<tr[nw].lz<<endl;
    return;
}
if(tr[nw].rl>rr||tr[nw].rr<rl){return;}
psh(nw);
upd(nw*2,rl,rr,v);upd(nw*2+1,rl,rr,v);
pull(nw);
}
int totlen;
void lisanhua(){
set<pair<int,int>>st;
set<int>stt;
for(int i=1;i<=n-1;i++){
    st.insert({lar[i],lar[i]});
    st.insert({rar[i],rar[i]});
    stt.insert(lar[i]);
    stt.insert(rar[i]);
}
for(auto it=stt.begin();it!=stt.end();it++){
    if(next(it)!=stt.end()){
        int v=(*it);
        int vv=(*next(it));
        if(vv-v>=2){
            st.insert({v+1,vv-1});
        }
    }
}
m=0;
for(auto it=st.begin();it!=st.end();it++){
    int l=(*it).first;int r=(*it).second;
    rmp[++m]={l,r};
   // cout<<l<<" "<<r<<endl;
}
totlen=rmp[m].second-rmp[1].first+1;
}
int fans[200005];

void dfs(int nw,int pa){
if(tr[1].mn==0){
    fans[nw]=totlen-tr[1].mnfq;
}else{
    fans[nw]=totlen;
}
for(int i=0;i<e[nw].size();i++){
    int v=e[nw][i].first;
    if(v==pa){continue;}
    int id=e[nw][i].second;
    upd(1,lar[id],rar[id],1);
    dfs(v,nw);
    upd(1,lar[id],rar[id],-1);
}


}


signed main(){
cin>>n>>m;
for(int i=1;i<=n-1;i++){
    int a;int b;
    cin>>a>>b>>lar[i]>>rar[i];
    e[a].push_back({b,i});
    e[b].push_back({a,i});
}
lisanhua();
buildtr(1,1,m);
/*
upd(1,1,4,1);
cout<<tr[1].mnfq<<"\n";
for(int nw=1;nw<=24;nw++){
    cout<<nw<<" "<<tr[nw].rl<<" "<<tr[nw].rr<<" "<<tr[nw].mn<<" "<<tr[nw].mnfq<<" "<<tr[nw].lz<<endl;
}

upd(1,2,3,1);
cout<<tr[1].mnfq<<"\n";

for(int nw=1;nw<=24;nw++){
    cout<<nw<<" "<<tr[nw].rl<<" "<<tr[nw].rr<<" "<<tr[nw].mn<<" "<<tr[nw].mnfq<<" "<<tr[nw].lz<<endl;
}

return 0;
cout<<endl<<endl;*/
dfs(1,0);
for(int i=2;i<=n;i++){
    cout<<fans[i]<<"\n";
}

}

Compilation message

Main.cpp: In function 'void dfs(int, int)':
Main.cpp:100:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 | for(int i=0;i<e[nw].size();i++){
      |             ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8536 KB Output is correct
2 Correct 3 ms 8540 KB Output is correct
3 Correct 3 ms 8840 KB Output is correct
4 Correct 3 ms 8796 KB Output is correct
5 Correct 3 ms 8796 KB Output is correct
6 Correct 3 ms 8796 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 3 ms 8540 KB Output is correct
10 Correct 3 ms 8540 KB Output is correct
11 Correct 3 ms 8540 KB Output is correct
12 Correct 3 ms 8540 KB Output is correct
13 Correct 3 ms 8540 KB Output is correct
14 Correct 3 ms 8760 KB Output is correct
15 Correct 1 ms 8592 KB Output is correct
16 Correct 2 ms 8536 KB Output is correct
17 Correct 3 ms 8536 KB Output is correct
18 Correct 3 ms 8540 KB Output is correct
19 Correct 3 ms 8540 KB Output is correct
20 Correct 3 ms 8540 KB Output is correct
21 Correct 3 ms 8540 KB Output is correct
22 Correct 3 ms 8540 KB Output is correct
23 Correct 2 ms 8536 KB Output is correct
24 Correct 2 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8536 KB Output is correct
2 Correct 3 ms 8540 KB Output is correct
3 Correct 3 ms 8840 KB Output is correct
4 Correct 3 ms 8796 KB Output is correct
5 Correct 3 ms 8796 KB Output is correct
6 Correct 3 ms 8796 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 3 ms 8540 KB Output is correct
10 Correct 3 ms 8540 KB Output is correct
11 Correct 3 ms 8540 KB Output is correct
12 Correct 3 ms 8540 KB Output is correct
13 Correct 3 ms 8540 KB Output is correct
14 Correct 3 ms 8760 KB Output is correct
15 Correct 1 ms 8592 KB Output is correct
16 Correct 2 ms 8536 KB Output is correct
17 Correct 3 ms 8536 KB Output is correct
18 Correct 3 ms 8540 KB Output is correct
19 Correct 3 ms 8540 KB Output is correct
20 Correct 3 ms 8540 KB Output is correct
21 Correct 3 ms 8540 KB Output is correct
22 Correct 3 ms 8540 KB Output is correct
23 Correct 2 ms 8536 KB Output is correct
24 Correct 2 ms 8536 KB Output is correct
25 Correct 3 ms 8540 KB Output is correct
26 Correct 3 ms 8540 KB Output is correct
27 Correct 4 ms 8796 KB Output is correct
28 Correct 4 ms 8796 KB Output is correct
29 Correct 3 ms 8796 KB Output is correct
30 Correct 3 ms 8796 KB Output is correct
31 Correct 3 ms 8796 KB Output is correct
32 Correct 4 ms 8796 KB Output is correct
33 Correct 4 ms 8916 KB Output is correct
34 Correct 4 ms 8796 KB Output is correct
35 Correct 3 ms 8540 KB Output is correct
36 Correct 3 ms 8540 KB Output is correct
37 Correct 4 ms 8796 KB Output is correct
38 Correct 4 ms 8796 KB Output is correct
39 Correct 3 ms 8696 KB Output is correct
40 Correct 3 ms 8796 KB Output is correct
41 Correct 3 ms 8796 KB Output is correct
42 Correct 3 ms 8796 KB Output is correct
43 Correct 3 ms 8796 KB Output is correct
44 Correct 4 ms 8704 KB Output is correct
45 Correct 4 ms 8792 KB Output is correct
46 Correct 4 ms 8796 KB Output is correct
47 Correct 4 ms 8796 KB Output is correct
48 Correct 3 ms 8796 KB Output is correct
49 Correct 4 ms 8796 KB Output is correct
50 Correct 3 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8536 KB Output is correct
2 Correct 3 ms 8540 KB Output is correct
3 Correct 3 ms 8840 KB Output is correct
4 Correct 3 ms 8796 KB Output is correct
5 Correct 3 ms 8796 KB Output is correct
6 Correct 3 ms 8796 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 3 ms 8540 KB Output is correct
10 Correct 3 ms 8540 KB Output is correct
11 Correct 3 ms 8540 KB Output is correct
12 Correct 3 ms 8540 KB Output is correct
13 Correct 3 ms 8540 KB Output is correct
14 Correct 3 ms 8760 KB Output is correct
15 Correct 1 ms 8592 KB Output is correct
16 Correct 2 ms 8536 KB Output is correct
17 Correct 3 ms 8536 KB Output is correct
18 Correct 3 ms 8540 KB Output is correct
19 Correct 3 ms 8540 KB Output is correct
20 Correct 3 ms 8540 KB Output is correct
21 Correct 3 ms 8540 KB Output is correct
22 Correct 3 ms 8540 KB Output is correct
23 Correct 2 ms 8536 KB Output is correct
24 Correct 2 ms 8536 KB Output is correct
25 Correct 58 ms 13180 KB Output is correct
26 Correct 63 ms 13212 KB Output is correct
27 Correct 106 ms 20820 KB Output is correct
28 Correct 107 ms 20732 KB Output is correct
29 Correct 81 ms 20300 KB Output is correct
30 Correct 82 ms 20112 KB Output is correct
31 Correct 12 ms 12376 KB Output is correct
32 Correct 12 ms 12380 KB Output is correct
33 Correct 12 ms 12380 KB Output is correct
34 Correct 12 ms 12380 KB Output is correct
35 Correct 60 ms 10580 KB Output is correct
36 Correct 57 ms 10832 KB Output is correct
37 Correct 133 ms 18000 KB Output is correct
38 Correct 108 ms 18256 KB Output is correct
39 Correct 80 ms 17492 KB Output is correct
40 Correct 83 ms 17476 KB Output is correct
41 Correct 12 ms 12120 KB Output is correct
42 Correct 13 ms 12124 KB Output is correct
43 Correct 59 ms 10320 KB Output is correct
44 Correct 63 ms 10304 KB Output is correct
45 Correct 114 ms 17912 KB Output is correct
46 Correct 112 ms 17704 KB Output is correct
47 Correct 87 ms 17236 KB Output is correct
48 Correct 82 ms 17112 KB Output is correct
49 Correct 12 ms 12124 KB Output is correct
50 Correct 13 ms 12088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8536 KB Output is correct
2 Correct 3 ms 8540 KB Output is correct
3 Correct 3 ms 8840 KB Output is correct
4 Correct 3 ms 8796 KB Output is correct
5 Correct 3 ms 8796 KB Output is correct
6 Correct 3 ms 8796 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 3 ms 8540 KB Output is correct
10 Correct 3 ms 8540 KB Output is correct
11 Correct 3 ms 8540 KB Output is correct
12 Correct 3 ms 8540 KB Output is correct
13 Correct 3 ms 8540 KB Output is correct
14 Correct 3 ms 8760 KB Output is correct
15 Correct 1 ms 8592 KB Output is correct
16 Correct 2 ms 8536 KB Output is correct
17 Correct 3 ms 8536 KB Output is correct
18 Correct 3 ms 8540 KB Output is correct
19 Correct 3 ms 8540 KB Output is correct
20 Correct 3 ms 8540 KB Output is correct
21 Correct 3 ms 8540 KB Output is correct
22 Correct 3 ms 8540 KB Output is correct
23 Correct 2 ms 8536 KB Output is correct
24 Correct 2 ms 8536 KB Output is correct
25 Correct 58 ms 13180 KB Output is correct
26 Correct 63 ms 13212 KB Output is correct
27 Correct 106 ms 20820 KB Output is correct
28 Correct 107 ms 20732 KB Output is correct
29 Correct 81 ms 20300 KB Output is correct
30 Correct 82 ms 20112 KB Output is correct
31 Correct 12 ms 12376 KB Output is correct
32 Correct 12 ms 12380 KB Output is correct
33 Correct 12 ms 12380 KB Output is correct
34 Correct 12 ms 12380 KB Output is correct
35 Correct 60 ms 10580 KB Output is correct
36 Correct 57 ms 10832 KB Output is correct
37 Correct 133 ms 18000 KB Output is correct
38 Correct 108 ms 18256 KB Output is correct
39 Correct 80 ms 17492 KB Output is correct
40 Correct 83 ms 17476 KB Output is correct
41 Correct 12 ms 12120 KB Output is correct
42 Correct 13 ms 12124 KB Output is correct
43 Correct 59 ms 10320 KB Output is correct
44 Correct 63 ms 10304 KB Output is correct
45 Correct 114 ms 17912 KB Output is correct
46 Correct 112 ms 17704 KB Output is correct
47 Correct 87 ms 17236 KB Output is correct
48 Correct 82 ms 17112 KB Output is correct
49 Correct 12 ms 12124 KB Output is correct
50 Correct 13 ms 12088 KB Output is correct
51 Correct 152 ms 20308 KB Output is correct
52 Correct 147 ms 20308 KB Output is correct
53 Correct 313 ms 34904 KB Output is correct
54 Correct 299 ms 34620 KB Output is correct
55 Correct 222 ms 33364 KB Output is correct
56 Correct 219 ms 33596 KB Output is correct
57 Correct 49 ms 19804 KB Output is correct
58 Correct 46 ms 19884 KB Output is correct
59 Correct 49 ms 19848 KB Output is correct
60 Correct 48 ms 19788 KB Output is correct
61 Correct 151 ms 14164 KB Output is correct
62 Correct 152 ms 14416 KB Output is correct
63 Correct 305 ms 27988 KB Output is correct
64 Correct 320 ms 28272 KB Output is correct
65 Correct 223 ms 26940 KB Output is correct
66 Correct 233 ms 26940 KB Output is correct
67 Correct 47 ms 18516 KB Output is correct
68 Correct 58 ms 18536 KB Output is correct
69 Correct 162 ms 13040 KB Output is correct
70 Correct 154 ms 13140 KB Output is correct
71 Correct 296 ms 27400 KB Output is correct
72 Correct 323 ms 27520 KB Output is correct
73 Correct 249 ms 25944 KB Output is correct
74 Correct 280 ms 26100 KB Output is correct
75 Correct 50 ms 18276 KB Output is correct
76 Correct 48 ms 18264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8536 KB Output is correct
2 Correct 3 ms 8540 KB Output is correct
3 Correct 3 ms 8840 KB Output is correct
4 Correct 3 ms 8796 KB Output is correct
5 Correct 3 ms 8796 KB Output is correct
6 Correct 3 ms 8796 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 2 ms 8540 KB Output is correct
9 Correct 3 ms 8540 KB Output is correct
10 Correct 3 ms 8540 KB Output is correct
11 Correct 3 ms 8540 KB Output is correct
12 Correct 3 ms 8540 KB Output is correct
13 Correct 3 ms 8540 KB Output is correct
14 Correct 3 ms 8760 KB Output is correct
15 Correct 1 ms 8592 KB Output is correct
16 Correct 2 ms 8536 KB Output is correct
17 Correct 3 ms 8536 KB Output is correct
18 Correct 3 ms 8540 KB Output is correct
19 Correct 3 ms 8540 KB Output is correct
20 Correct 3 ms 8540 KB Output is correct
21 Correct 3 ms 8540 KB Output is correct
22 Correct 3 ms 8540 KB Output is correct
23 Correct 2 ms 8536 KB Output is correct
24 Correct 2 ms 8536 KB Output is correct
25 Correct 3 ms 8540 KB Output is correct
26 Correct 3 ms 8540 KB Output is correct
27 Correct 4 ms 8796 KB Output is correct
28 Correct 4 ms 8796 KB Output is correct
29 Correct 3 ms 8796 KB Output is correct
30 Correct 3 ms 8796 KB Output is correct
31 Correct 3 ms 8796 KB Output is correct
32 Correct 4 ms 8796 KB Output is correct
33 Correct 4 ms 8916 KB Output is correct
34 Correct 4 ms 8796 KB Output is correct
35 Correct 3 ms 8540 KB Output is correct
36 Correct 3 ms 8540 KB Output is correct
37 Correct 4 ms 8796 KB Output is correct
38 Correct 4 ms 8796 KB Output is correct
39 Correct 3 ms 8696 KB Output is correct
40 Correct 3 ms 8796 KB Output is correct
41 Correct 3 ms 8796 KB Output is correct
42 Correct 3 ms 8796 KB Output is correct
43 Correct 3 ms 8796 KB Output is correct
44 Correct 4 ms 8704 KB Output is correct
45 Correct 4 ms 8792 KB Output is correct
46 Correct 4 ms 8796 KB Output is correct
47 Correct 4 ms 8796 KB Output is correct
48 Correct 3 ms 8796 KB Output is correct
49 Correct 4 ms 8796 KB Output is correct
50 Correct 3 ms 8796 KB Output is correct
51 Correct 58 ms 13180 KB Output is correct
52 Correct 63 ms 13212 KB Output is correct
53 Correct 106 ms 20820 KB Output is correct
54 Correct 107 ms 20732 KB Output is correct
55 Correct 81 ms 20300 KB Output is correct
56 Correct 82 ms 20112 KB Output is correct
57 Correct 12 ms 12376 KB Output is correct
58 Correct 12 ms 12380 KB Output is correct
59 Correct 12 ms 12380 KB Output is correct
60 Correct 12 ms 12380 KB Output is correct
61 Correct 60 ms 10580 KB Output is correct
62 Correct 57 ms 10832 KB Output is correct
63 Correct 133 ms 18000 KB Output is correct
64 Correct 108 ms 18256 KB Output is correct
65 Correct 80 ms 17492 KB Output is correct
66 Correct 83 ms 17476 KB Output is correct
67 Correct 12 ms 12120 KB Output is correct
68 Correct 13 ms 12124 KB Output is correct
69 Correct 59 ms 10320 KB Output is correct
70 Correct 63 ms 10304 KB Output is correct
71 Correct 114 ms 17912 KB Output is correct
72 Correct 112 ms 17704 KB Output is correct
73 Correct 87 ms 17236 KB Output is correct
74 Correct 82 ms 17112 KB Output is correct
75 Correct 12 ms 12124 KB Output is correct
76 Correct 13 ms 12088 KB Output is correct
77 Correct 152 ms 20308 KB Output is correct
78 Correct 147 ms 20308 KB Output is correct
79 Correct 313 ms 34904 KB Output is correct
80 Correct 299 ms 34620 KB Output is correct
81 Correct 222 ms 33364 KB Output is correct
82 Correct 219 ms 33596 KB Output is correct
83 Correct 49 ms 19804 KB Output is correct
84 Correct 46 ms 19884 KB Output is correct
85 Correct 49 ms 19848 KB Output is correct
86 Correct 48 ms 19788 KB Output is correct
87 Correct 151 ms 14164 KB Output is correct
88 Correct 152 ms 14416 KB Output is correct
89 Correct 305 ms 27988 KB Output is correct
90 Correct 320 ms 28272 KB Output is correct
91 Correct 223 ms 26940 KB Output is correct
92 Correct 233 ms 26940 KB Output is correct
93 Correct 47 ms 18516 KB Output is correct
94 Correct 58 ms 18536 KB Output is correct
95 Correct 162 ms 13040 KB Output is correct
96 Correct 154 ms 13140 KB Output is correct
97 Correct 296 ms 27400 KB Output is correct
98 Correct 323 ms 27520 KB Output is correct
99 Correct 249 ms 25944 KB Output is correct
100 Correct 280 ms 26100 KB Output is correct
101 Correct 50 ms 18276 KB Output is correct
102 Correct 48 ms 18264 KB Output is correct
103 Correct 156 ms 20636 KB Output is correct
104 Correct 158 ms 20640 KB Output is correct
105 Runtime error 379 ms 138120 KB Execution killed with signal 11
106 Halted 0 ms 0 KB -