Submission #750898

# Submission time Handle Problem Language Result Execution time Memory
750898 2023-05-30T13:06:12 Z edogawa_something Vinjete (COI22_vinjete) C++17
100 / 100
671 ms 339464 KB
#include<bits/stdc++.h>
#include<chrono>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef bool bl;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
#define ordered_set tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0);cin.tie();
#define test ll qqqqq;cin>>qqqqq;while(qqqqq--)
#define test1 ll qqqqq=1;while(qqqqq--)
#define F first
#define S second
#define forn(i,n) for(int i=0;i<n;i++)
#define forx(i,j,n) for(int i=j;i<n;i++)
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define all(v) v.begin(),v.end()
#define lb lower_bound
#define ub upper_bound
#define pow powww
#define prtll(x) printf("%lld",x)
#define prtld(x) printf("%Lf",x)
#define prtst(x) printf("%s",x)
#define prtch(x) printf("%c",x)
#define measure chrono::high_resolution_clock::now()
#define duration chrono::duration_cast<chrono::milliseconds>(end-start)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
const ll dx[]{1,0,-1,0,1,-1,1,-1};
const ll dy[]{0,-1,0,1,1,-1,-1,1};
const ll inf=1e18;
const ll mod=1e9+7;
const ll LM=1e8+1;
const ll M=6e6+10;
const ll MM=4002;
const ll MMM=501;
const ld pi=acos(-1);
//const ll mod=998244353;
ll pow(ll r,ll to,ll m=mod){
  ll res=1;
  r%=m;
  while(to){
    if((to&1)){
      res*=r,res%=m;
    }
    r*=r,r%=m;
    to=(to>>1);
  }
  return res;
}
ll le[M],ri[M],val[M],cnt[M],has[M],t=1;
ll n,m,a[M];
struct seg{
  void update(ll l,ll r,ll v,ll x,ll lx,ll rx){
    if(rx<=l||r<=lx)
    return;
    if(rx-lx==1){
      val[x]+=v;
      cnt[x]=1;
      return;
    }
    if(rx<=r&&lx>=l){
      has[x]+=v;
      return;
    }
    else{
      ll mid=((lx+rx)>>1);
      if(le[x]==0){
      le[x]=t++;
      cnt[le[x]]=mid-lx;
      }
      if(ri[x]==0){
      ri[x]=t++;
      cnt[ri[x]]=rx-mid;
      }
      update(l,r,v,le[x],lx,mid);
      update(l,r,v,ri[x],mid,rx);
      if(val[ri[x]]+has[ri[x]]==val[le[x]]+has[le[x]])
      cnt[x]=cnt[ri[x]]+cnt[le[x]];
      else if(val[ri[x]]+has[ri[x]]<val[le[x]]+has[le[x]])
      cnt[x]=cnt[ri[x]];
      else
      cnt[x]=cnt[le[x]];
      val[x]=min(val[le[x]]+has[le[x]],val[ri[x]]+has[ri[x]]);
    }
  }
  void update(ll l,ll r,ll v){
    update(l,r,v,0,0,(1<<30));
  }
  ll query(){
    return (1<<30)-cnt[0];
  }
}s;
vector<pair<ll,pii>>v[M];
ll ans[M];
void dfs(ll r,ll pa){
  ans[r]=s.query();
  for(auto it:v[r]){
    if(it.F==pa)
    continue;
    s.update(it.S.F,it.S.S,1);
    dfs(it.F,r);
    s.update(it.S.F,it.S.S,-1);
  }
}
int main(){
  fast
  //freopen("gen.txt","r",stdin);
  auto start=measure;
  test1{
    cin>>n>>m;
    forn(i,n-1){
      ll x,y,l,r;
      cin>>x>>y>>l>>r;
      v[x].pb({y,{l-1,r}});
      v[y].pb({x,{l-1,r}});
    }
    dfs(1,-1);
    forx(i,2,n+1){
      cout<<ans[i]<<'\n';
    }
  }
  auto end=measure;
  auto dur=duration;
  //cout<<fixed<<dur.count()<<'\n';
  return 0;
}
/*
*/
# Verdict Execution time Memory Grader output
1 Correct 69 ms 141480 KB Output is correct
2 Correct 68 ms 141484 KB Output is correct
3 Correct 66 ms 141444 KB Output is correct
4 Correct 68 ms 141516 KB Output is correct
5 Correct 66 ms 141516 KB Output is correct
6 Correct 68 ms 141436 KB Output is correct
7 Correct 66 ms 141236 KB Output is correct
8 Correct 65 ms 141260 KB Output is correct
9 Correct 66 ms 141260 KB Output is correct
10 Correct 65 ms 141300 KB Output is correct
11 Correct 66 ms 141412 KB Output is correct
12 Correct 67 ms 141372 KB Output is correct
13 Correct 67 ms 141304 KB Output is correct
14 Correct 66 ms 141388 KB Output is correct
15 Correct 65 ms 141248 KB Output is correct
16 Correct 64 ms 141292 KB Output is correct
17 Correct 66 ms 141356 KB Output is correct
18 Correct 68 ms 141288 KB Output is correct
19 Correct 66 ms 141336 KB Output is correct
20 Correct 66 ms 141280 KB Output is correct
21 Correct 65 ms 141388 KB Output is correct
22 Correct 66 ms 141396 KB Output is correct
23 Correct 68 ms 141208 KB Output is correct
24 Correct 65 ms 141232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 141480 KB Output is correct
2 Correct 68 ms 141484 KB Output is correct
3 Correct 66 ms 141444 KB Output is correct
4 Correct 68 ms 141516 KB Output is correct
5 Correct 66 ms 141516 KB Output is correct
6 Correct 68 ms 141436 KB Output is correct
7 Correct 66 ms 141236 KB Output is correct
8 Correct 65 ms 141260 KB Output is correct
9 Correct 66 ms 141260 KB Output is correct
10 Correct 65 ms 141300 KB Output is correct
11 Correct 66 ms 141412 KB Output is correct
12 Correct 67 ms 141372 KB Output is correct
13 Correct 67 ms 141304 KB Output is correct
14 Correct 66 ms 141388 KB Output is correct
15 Correct 65 ms 141248 KB Output is correct
16 Correct 64 ms 141292 KB Output is correct
17 Correct 66 ms 141356 KB Output is correct
18 Correct 68 ms 141288 KB Output is correct
19 Correct 66 ms 141336 KB Output is correct
20 Correct 66 ms 141280 KB Output is correct
21 Correct 65 ms 141388 KB Output is correct
22 Correct 66 ms 141396 KB Output is correct
23 Correct 68 ms 141208 KB Output is correct
24 Correct 65 ms 141232 KB Output is correct
25 Correct 67 ms 141504 KB Output is correct
26 Correct 72 ms 141440 KB Output is correct
27 Correct 74 ms 144264 KB Output is correct
28 Correct 70 ms 144208 KB Output is correct
29 Correct 68 ms 142636 KB Output is correct
30 Correct 66 ms 142668 KB Output is correct
31 Correct 68 ms 144184 KB Output is correct
32 Correct 74 ms 144208 KB Output is correct
33 Correct 70 ms 144212 KB Output is correct
34 Correct 75 ms 144204 KB Output is correct
35 Correct 67 ms 141304 KB Output is correct
36 Correct 67 ms 141388 KB Output is correct
37 Correct 69 ms 144088 KB Output is correct
38 Correct 71 ms 144060 KB Output is correct
39 Correct 67 ms 142512 KB Output is correct
40 Correct 67 ms 142548 KB Output is correct
41 Correct 69 ms 144076 KB Output is correct
42 Correct 68 ms 144084 KB Output is correct
43 Correct 66 ms 141364 KB Output is correct
44 Correct 67 ms 141364 KB Output is correct
45 Correct 68 ms 144076 KB Output is correct
46 Correct 69 ms 144096 KB Output is correct
47 Correct 71 ms 142600 KB Output is correct
48 Correct 70 ms 142540 KB Output is correct
49 Correct 68 ms 144092 KB Output is correct
50 Correct 71 ms 144044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 141480 KB Output is correct
2 Correct 68 ms 141484 KB Output is correct
3 Correct 66 ms 141444 KB Output is correct
4 Correct 68 ms 141516 KB Output is correct
5 Correct 66 ms 141516 KB Output is correct
6 Correct 68 ms 141436 KB Output is correct
7 Correct 66 ms 141236 KB Output is correct
8 Correct 65 ms 141260 KB Output is correct
9 Correct 66 ms 141260 KB Output is correct
10 Correct 65 ms 141300 KB Output is correct
11 Correct 66 ms 141412 KB Output is correct
12 Correct 67 ms 141372 KB Output is correct
13 Correct 67 ms 141304 KB Output is correct
14 Correct 66 ms 141388 KB Output is correct
15 Correct 65 ms 141248 KB Output is correct
16 Correct 64 ms 141292 KB Output is correct
17 Correct 66 ms 141356 KB Output is correct
18 Correct 68 ms 141288 KB Output is correct
19 Correct 66 ms 141336 KB Output is correct
20 Correct 66 ms 141280 KB Output is correct
21 Correct 65 ms 141388 KB Output is correct
22 Correct 66 ms 141396 KB Output is correct
23 Correct 68 ms 141208 KB Output is correct
24 Correct 65 ms 141232 KB Output is correct
25 Correct 116 ms 149868 KB Output is correct
26 Correct 114 ms 149956 KB Output is correct
27 Correct 139 ms 152760 KB Output is correct
28 Correct 136 ms 152764 KB Output is correct
29 Correct 115 ms 152268 KB Output is correct
30 Correct 110 ms 152256 KB Output is correct
31 Correct 73 ms 143820 KB Output is correct
32 Correct 73 ms 143816 KB Output is correct
33 Correct 72 ms 143828 KB Output is correct
34 Correct 72 ms 143820 KB Output is correct
35 Correct 122 ms 144892 KB Output is correct
36 Correct 114 ms 145224 KB Output is correct
37 Correct 139 ms 147740 KB Output is correct
38 Correct 147 ms 148104 KB Output is correct
39 Correct 120 ms 147288 KB Output is correct
40 Correct 115 ms 147180 KB Output is correct
41 Correct 76 ms 143204 KB Output is correct
42 Correct 74 ms 143176 KB Output is correct
43 Correct 119 ms 144420 KB Output is correct
44 Correct 117 ms 144440 KB Output is correct
45 Correct 136 ms 147212 KB Output is correct
46 Correct 135 ms 147176 KB Output is correct
47 Correct 116 ms 146636 KB Output is correct
48 Correct 114 ms 146584 KB Output is correct
49 Correct 72 ms 143104 KB Output is correct
50 Correct 73 ms 143136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 141480 KB Output is correct
2 Correct 68 ms 141484 KB Output is correct
3 Correct 66 ms 141444 KB Output is correct
4 Correct 68 ms 141516 KB Output is correct
5 Correct 66 ms 141516 KB Output is correct
6 Correct 68 ms 141436 KB Output is correct
7 Correct 66 ms 141236 KB Output is correct
8 Correct 65 ms 141260 KB Output is correct
9 Correct 66 ms 141260 KB Output is correct
10 Correct 65 ms 141300 KB Output is correct
11 Correct 66 ms 141412 KB Output is correct
12 Correct 67 ms 141372 KB Output is correct
13 Correct 67 ms 141304 KB Output is correct
14 Correct 66 ms 141388 KB Output is correct
15 Correct 65 ms 141248 KB Output is correct
16 Correct 64 ms 141292 KB Output is correct
17 Correct 66 ms 141356 KB Output is correct
18 Correct 68 ms 141288 KB Output is correct
19 Correct 66 ms 141336 KB Output is correct
20 Correct 66 ms 141280 KB Output is correct
21 Correct 65 ms 141388 KB Output is correct
22 Correct 66 ms 141396 KB Output is correct
23 Correct 68 ms 141208 KB Output is correct
24 Correct 65 ms 141232 KB Output is correct
25 Correct 116 ms 149868 KB Output is correct
26 Correct 114 ms 149956 KB Output is correct
27 Correct 139 ms 152760 KB Output is correct
28 Correct 136 ms 152764 KB Output is correct
29 Correct 115 ms 152268 KB Output is correct
30 Correct 110 ms 152256 KB Output is correct
31 Correct 73 ms 143820 KB Output is correct
32 Correct 73 ms 143816 KB Output is correct
33 Correct 72 ms 143828 KB Output is correct
34 Correct 72 ms 143820 KB Output is correct
35 Correct 122 ms 144892 KB Output is correct
36 Correct 114 ms 145224 KB Output is correct
37 Correct 139 ms 147740 KB Output is correct
38 Correct 147 ms 148104 KB Output is correct
39 Correct 120 ms 147288 KB Output is correct
40 Correct 115 ms 147180 KB Output is correct
41 Correct 76 ms 143204 KB Output is correct
42 Correct 74 ms 143176 KB Output is correct
43 Correct 119 ms 144420 KB Output is correct
44 Correct 117 ms 144440 KB Output is correct
45 Correct 136 ms 147212 KB Output is correct
46 Correct 135 ms 147176 KB Output is correct
47 Correct 116 ms 146636 KB Output is correct
48 Correct 114 ms 146584 KB Output is correct
49 Correct 72 ms 143104 KB Output is correct
50 Correct 73 ms 143136 KB Output is correct
51 Correct 185 ms 163020 KB Output is correct
52 Correct 190 ms 163072 KB Output is correct
53 Correct 266 ms 170136 KB Output is correct
54 Correct 275 ms 170052 KB Output is correct
55 Correct 199 ms 168788 KB Output is correct
56 Correct 201 ms 168804 KB Output is correct
57 Correct 89 ms 150220 KB Output is correct
58 Correct 91 ms 150200 KB Output is correct
59 Correct 94 ms 150248 KB Output is correct
60 Correct 101 ms 150116 KB Output is correct
61 Correct 201 ms 150860 KB Output is correct
62 Correct 203 ms 151224 KB Output is correct
63 Correct 284 ms 157532 KB Output is correct
64 Correct 277 ms 157848 KB Output is correct
65 Correct 227 ms 156780 KB Output is correct
66 Correct 205 ms 156380 KB Output is correct
67 Correct 89 ms 147744 KB Output is correct
68 Correct 94 ms 147652 KB Output is correct
69 Correct 207 ms 149112 KB Output is correct
70 Correct 212 ms 149108 KB Output is correct
71 Correct 289 ms 156196 KB Output is correct
72 Correct 274 ms 156148 KB Output is correct
73 Correct 241 ms 154576 KB Output is correct
74 Correct 214 ms 154684 KB Output is correct
75 Correct 93 ms 147400 KB Output is correct
76 Correct 94 ms 147380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 141480 KB Output is correct
2 Correct 68 ms 141484 KB Output is correct
3 Correct 66 ms 141444 KB Output is correct
4 Correct 68 ms 141516 KB Output is correct
5 Correct 66 ms 141516 KB Output is correct
6 Correct 68 ms 141436 KB Output is correct
7 Correct 66 ms 141236 KB Output is correct
8 Correct 65 ms 141260 KB Output is correct
9 Correct 66 ms 141260 KB Output is correct
10 Correct 65 ms 141300 KB Output is correct
11 Correct 66 ms 141412 KB Output is correct
12 Correct 67 ms 141372 KB Output is correct
13 Correct 67 ms 141304 KB Output is correct
14 Correct 66 ms 141388 KB Output is correct
15 Correct 65 ms 141248 KB Output is correct
16 Correct 64 ms 141292 KB Output is correct
17 Correct 66 ms 141356 KB Output is correct
18 Correct 68 ms 141288 KB Output is correct
19 Correct 66 ms 141336 KB Output is correct
20 Correct 66 ms 141280 KB Output is correct
21 Correct 65 ms 141388 KB Output is correct
22 Correct 66 ms 141396 KB Output is correct
23 Correct 68 ms 141208 KB Output is correct
24 Correct 65 ms 141232 KB Output is correct
25 Correct 67 ms 141504 KB Output is correct
26 Correct 72 ms 141440 KB Output is correct
27 Correct 74 ms 144264 KB Output is correct
28 Correct 70 ms 144208 KB Output is correct
29 Correct 68 ms 142636 KB Output is correct
30 Correct 66 ms 142668 KB Output is correct
31 Correct 68 ms 144184 KB Output is correct
32 Correct 74 ms 144208 KB Output is correct
33 Correct 70 ms 144212 KB Output is correct
34 Correct 75 ms 144204 KB Output is correct
35 Correct 67 ms 141304 KB Output is correct
36 Correct 67 ms 141388 KB Output is correct
37 Correct 69 ms 144088 KB Output is correct
38 Correct 71 ms 144060 KB Output is correct
39 Correct 67 ms 142512 KB Output is correct
40 Correct 67 ms 142548 KB Output is correct
41 Correct 69 ms 144076 KB Output is correct
42 Correct 68 ms 144084 KB Output is correct
43 Correct 66 ms 141364 KB Output is correct
44 Correct 67 ms 141364 KB Output is correct
45 Correct 68 ms 144076 KB Output is correct
46 Correct 69 ms 144096 KB Output is correct
47 Correct 71 ms 142600 KB Output is correct
48 Correct 70 ms 142540 KB Output is correct
49 Correct 68 ms 144092 KB Output is correct
50 Correct 71 ms 144044 KB Output is correct
51 Correct 116 ms 149868 KB Output is correct
52 Correct 114 ms 149956 KB Output is correct
53 Correct 139 ms 152760 KB Output is correct
54 Correct 136 ms 152764 KB Output is correct
55 Correct 115 ms 152268 KB Output is correct
56 Correct 110 ms 152256 KB Output is correct
57 Correct 73 ms 143820 KB Output is correct
58 Correct 73 ms 143816 KB Output is correct
59 Correct 72 ms 143828 KB Output is correct
60 Correct 72 ms 143820 KB Output is correct
61 Correct 122 ms 144892 KB Output is correct
62 Correct 114 ms 145224 KB Output is correct
63 Correct 139 ms 147740 KB Output is correct
64 Correct 147 ms 148104 KB Output is correct
65 Correct 120 ms 147288 KB Output is correct
66 Correct 115 ms 147180 KB Output is correct
67 Correct 76 ms 143204 KB Output is correct
68 Correct 74 ms 143176 KB Output is correct
69 Correct 119 ms 144420 KB Output is correct
70 Correct 117 ms 144440 KB Output is correct
71 Correct 136 ms 147212 KB Output is correct
72 Correct 135 ms 147176 KB Output is correct
73 Correct 116 ms 146636 KB Output is correct
74 Correct 114 ms 146584 KB Output is correct
75 Correct 72 ms 143104 KB Output is correct
76 Correct 73 ms 143136 KB Output is correct
77 Correct 185 ms 163020 KB Output is correct
78 Correct 190 ms 163072 KB Output is correct
79 Correct 266 ms 170136 KB Output is correct
80 Correct 275 ms 170052 KB Output is correct
81 Correct 199 ms 168788 KB Output is correct
82 Correct 201 ms 168804 KB Output is correct
83 Correct 89 ms 150220 KB Output is correct
84 Correct 91 ms 150200 KB Output is correct
85 Correct 94 ms 150248 KB Output is correct
86 Correct 101 ms 150116 KB Output is correct
87 Correct 201 ms 150860 KB Output is correct
88 Correct 203 ms 151224 KB Output is correct
89 Correct 284 ms 157532 KB Output is correct
90 Correct 277 ms 157848 KB Output is correct
91 Correct 227 ms 156780 KB Output is correct
92 Correct 205 ms 156380 KB Output is correct
93 Correct 89 ms 147744 KB Output is correct
94 Correct 94 ms 147652 KB Output is correct
95 Correct 207 ms 149112 KB Output is correct
96 Correct 212 ms 149108 KB Output is correct
97 Correct 289 ms 156196 KB Output is correct
98 Correct 274 ms 156148 KB Output is correct
99 Correct 241 ms 154576 KB Output is correct
100 Correct 214 ms 154684 KB Output is correct
101 Correct 93 ms 147400 KB Output is correct
102 Correct 94 ms 147380 KB Output is correct
103 Correct 217 ms 163468 KB Output is correct
104 Correct 214 ms 163484 KB Output is correct
105 Correct 602 ms 339412 KB Output is correct
106 Correct 671 ms 339464 KB Output is correct
107 Correct 336 ms 247052 KB Output is correct
108 Correct 330 ms 247080 KB Output is correct
109 Correct 125 ms 188636 KB Output is correct
110 Correct 126 ms 188620 KB Output is correct
111 Correct 129 ms 188576 KB Output is correct
112 Correct 127 ms 188736 KB Output is correct
113 Correct 251 ms 152088 KB Output is correct
114 Correct 238 ms 151712 KB Output is correct
115 Correct 553 ms 327584 KB Output is correct
116 Correct 552 ms 327864 KB Output is correct
117 Correct 309 ms 235032 KB Output is correct
118 Correct 314 ms 234572 KB Output is correct
119 Correct 129 ms 186216 KB Output is correct
120 Correct 128 ms 186240 KB Output is correct
121 Correct 258 ms 149764 KB Output is correct
122 Correct 257 ms 149760 KB Output is correct
123 Correct 537 ms 326136 KB Output is correct
124 Correct 533 ms 325932 KB Output is correct
125 Correct 336 ms 233120 KB Output is correct
126 Correct 317 ms 233080 KB Output is correct
127 Correct 137 ms 185844 KB Output is correct
128 Correct 138 ms 185932 KB Output is correct