This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ZTTjuLOs n,q;
#define HM4px6S4 out[d][u]=now;
#define g6mtl6Hv push(int
#define xljcJJcO if(tp==2)
#define dcSWyLOf sz[u]+=get_sz(v,u);
#define A36SHG42 inf<<1;
#define hIaodsKO 0;
#define bpQnlTZZ get_cen(v,u,half);
#define oTWOQmVl update(u,v,w-old);
#define kmce8oN4 in[LOG][N],out[LOG][N],now;
#define IZUtI7NN del[N];
#define l3yJ5YXQ LOG=17;
#define SpDuHoHu res=min(res,a+b);
#define RWbDJyvR half)
#define kXHbO1AY void
#define GvTlAGAL st::update(1,1,now,in[dep[v]][x],out[dep[v]][x],w);
#define aSsJ0Owl in[d][u]=++now;
#define fqlExGlU if(!del[v])
#define hDlU2lDE CD(int
#define CplhI0iB sz[u]=1;
#define VVyNccFD int
#define hspL2wh0 update(id<<1|1,mid+1,r,ql,qr,v);
#define GYiWOx1M l,int
#define MA4m1aCK main()
#define Kh1LBnmJ if(in[dep[v]][x]<in[dep[v]][y])
#define SVhdLX17 CD(1,0);
#define KBCLPIjr else
#define mVm6wWad cout<<seek(u)<<'\n';
#define jSxoahyD lz[id]=0;
#define jD0xMvZP st::init();
#define Gp2l3V2T y,long
#define duCMQKKd apply(id<<1,lz[id]);
#define Rsxr0kUJ cin>>tp;
#define nvmuKvFw cost;
#define pJ5mwMNC {
#define M8mAfA5p sz[N],dep[N],p[N];
#define HyvZwdg0 st[4*N*LOG],lz[4*N*LOG];
#define A7Mqbj0S u,int
#define IZFfdR9P v=u;v;v=p[v])
#define uCIxcZqH vector<int>
#define Mm47Wbmc cin>>u>>v>>w;
#define JN1IIf8p tp;
#define PfhZ0yxO return;
#define kMnKT59b update(id<<1,l,mid,ql,qr,v);
#define aOvmdBhc g[N];
#define w6NZKQLb st[id]+=v;
#define JZgkBOr1 id,int
#define JKYlRtZc seek(int
#define WE3A1wm9 fa,int
#define JsODOaho v=(dep[x]<dep[y]?x:y);
#define iJgm0B4Z cost[{u,v}]=w;
#define WApe3ag8 u,v,w;
#define yrFE3TE3 i=1;i<=4*now;i++)
#define pjGcHwb2 a-=inf;
#define Ul82L21l }
#define Hm424j9y res;
#define aVvbsCnx swap(u,v);
#define Mgd5HBZZ if(tp==1)
#define WdwmQinF apply(int
#define twPrOLgS dep[u]=dep[fa]+1;
#define YotXLhJP ql,int
#define oAXTA48Z return
#define A6VRsx0W st
#define gST0kxVf if(ql<=l&&r<=qr)
#define kGVsCvuK soak(int
#define JAKYGrEZ for(int
#define OYs0lGeK using
#define lRuaK1dP i=1;i<n;i++){
#define J4RWtRv1 namespace
#define OultoGWr if(!del[v]&&v!=fa)
#define WQ5HHAKq get(int
#define K8gcQVPL lz[id]+=v;
#define LM68xp8T dfs(u,0,dep[u]);
#define P6AnDAsX apply(id,v);
#define FBaOasnl w)
#define Yke60nP3 u=get_cen(u,0,get_sz(u,0)>>1);
#define QvOu4XFT x,int
#define KEPo5mij v:g[u])
#define HUrkc26x soak(u);
#define oZAoGmlB res=inf;
#define qvxNjx0a init()
#define CKUmUBWF r,int
#define aM4U3hrw del[u]=1;
#define kRPimmAo if(res==inf)
#define mH2JNFVh x:cost)
#define Sugkwky1 a=st::get(1,1,now,in[dep[v]][u],in[dep[v]][u]);
#define qLguRON0 b=st::get(1,1,now,in[dep[v]][v],out[dep[v]][v]);
#define GFC7vjk9 qr,long
#define k4DwGGZ0 on[N];
#define MtU0BFpv id)
#define DT9EM4fp long
#define W0H67J1S CD(v,u);
#define HJ3buAFf if(u>v)
#define VWukd67J g[u].push_back(v);
#define N148qXW7 st[id]=min(st[id<<1],st[id<<1|1]);
#define TyQ0pWnn st[i]=inf;
#define StH0ulwI while(q--)
#define Fe73aIsU g[v].push_back(u);
#define KT1ZBXkH update(int
#define H5jbdHZF p[u]=fa;
#define uljl0ivM push(id);
#define JDd3ZkJr ios::sync_with_stdio(false);
#define AUClslB4 for(auto
#define sG0doFrL for(;v;v=p[v])
#define AnagPUeG cin.tie(0);
#define bvyijl58 sz[u];
#define nVNoNLO0 if(!del[v]&&v!=fa&&sz[v]>half)
#define iWFJTVic dfs(int
#define wNAnQkse old=cost[{u,v}];
#define liGgq2MP mid=(l+r)>>1;
#define PTlD4E0n std;
#define sA4YGD0Y cin>>n>>q;
#define yD4ieMZ0 u)
#define RWKC28AH on[u]^=1;
#define E12s2KTY u;cin>>u;
#define HlCgIXen st::update(1,1,now,in[dep[v]][u],in[dep[v]][u],(on[u]?-1:1)*inf);
#define Q7fksCF7 const
#define C0wgciqm update(x.first.first,x.first.second,x.second);
#define oLQAXUBH swap(x,y);
#define n9d4T4tF get_cen(int
#define ZNTYU9dv v)
#define ksWAQXwV if(!on[u])
#define qK2FSqWn u;
#define LC6Gwxdo st[id];
#define C9c92swN map<pair<int,int>,int>
#define NRTllDT8 inf=1e17;
#define D7BHTuxe bool
#define voYJ0TQG if(fa)
#define nIlVN7aB dfs(v,u,d);
#define XZY17Z9m id,long
#define SbrBwLWo min(get(id<<1,l,mid,ql,qr),get(id<<1|1,mid+1,r,ql,qr));
#define j4tcg3Kt qr)
#define nGxnnGhe apply(id<<1|1,lz[id]);
#define CYfOB32b get_sz(int
#define rU0UhB4k d)
#define ubpB3oHh if(!lz[id])
#define XoQpwBIq N=1e5+5;
#define XsLYyFhU if(r<ql||qr<l)
#define eWF3Z9oR -1;
#define QuSIunKx fa)
OYs0lGeK J4RWtRv1 PTlD4E0n Q7fksCF7 VVyNccFD
XoQpwBIq Q7fksCF7 VVyNccFD l3yJ5YXQ Q7fksCF7
DT9EM4fp DT9EM4fp NRTllDT8 VVyNccFD ZTTjuLOs
uCIxcZqH aOvmdBhc C9c92swN nvmuKvFw D7BHTuxe
IZUtI7NN VVyNccFD M8mAfA5p VVyNccFD kmce8oN4
D7BHTuxe k4DwGGZ0 J4RWtRv1 A6VRsx0W pJ5mwMNC
DT9EM4fp DT9EM4fp HyvZwdg0 kXHbO1AY qvxNjx0a
pJ5mwMNC JAKYGrEZ yrFE3TE3 TyQ0pWnn Ul82L21l
kXHbO1AY WdwmQinF XZY17Z9m DT9EM4fp ZNTYU9dv
pJ5mwMNC w6NZKQLb K8gcQVPL Ul82L21l kXHbO1AY
g6mtl6Hv MtU0BFpv pJ5mwMNC ubpB3oHh PfhZ0yxO
duCMQKKd nGxnnGhe jSxoahyD Ul82L21l kXHbO1AY
KT1ZBXkH JZgkBOr1 GYiWOx1M CKUmUBWF YotXLhJP
GFC7vjk9 DT9EM4fp ZNTYU9dv pJ5mwMNC XsLYyFhU
PfhZ0yxO gST0kxVf pJ5mwMNC P6AnDAsX PfhZ0yxO
Ul82L21l uljl0ivM VVyNccFD liGgq2MP kMnKT59b
hspL2wh0 N148qXW7 Ul82L21l DT9EM4fp DT9EM4fp
WQ5HHAKq JZgkBOr1 GYiWOx1M CKUmUBWF YotXLhJP
j4tcg3Kt pJ5mwMNC XsLYyFhU oAXTA48Z A36SHG42
gST0kxVf oAXTA48Z LC6Gwxdo VVyNccFD liGgq2MP
uljl0ivM oAXTA48Z SbrBwLWo Ul82L21l Ul82L21l
VVyNccFD CYfOB32b A7Mqbj0S QuSIunKx pJ5mwMNC
CplhI0iB JAKYGrEZ KEPo5mij OultoGWr dcSWyLOf
oAXTA48Z bvyijl58 Ul82L21l VVyNccFD n9d4T4tF
A7Mqbj0S WE3A1wm9 RWbDJyvR pJ5mwMNC JAKYGrEZ
KEPo5mij nVNoNLO0 oAXTA48Z bpQnlTZZ oAXTA48Z
qK2FSqWn Ul82L21l kXHbO1AY iWFJTVic A7Mqbj0S
WE3A1wm9 rU0UhB4k pJ5mwMNC aSsJ0Owl JAKYGrEZ
KEPo5mij OultoGWr nIlVN7aB HM4px6S4 Ul82L21l
kXHbO1AY hDlU2lDE A7Mqbj0S QuSIunKx pJ5mwMNC
Yke60nP3 aM4U3hrw H5jbdHZF voYJ0TQG twPrOLgS
LM68xp8T JAKYGrEZ KEPo5mij pJ5mwMNC fqlExGlU
W0H67J1S Ul82L21l Ul82L21l kXHbO1AY KT1ZBXkH
QvOu4XFT Gp2l3V2T DT9EM4fp FBaOasnl pJ5mwMNC
VVyNccFD JsODOaho sG0doFrL pJ5mwMNC Kh1LBnmJ
oLQAXUBH GvTlAGAL Ul82L21l Ul82L21l kXHbO1AY
kGVsCvuK yD4ieMZ0 pJ5mwMNC RWKC28AH JAKYGrEZ
IZFfdR9P pJ5mwMNC HlCgIXen Ul82L21l Ul82L21l
VVyNccFD JKYlRtZc yD4ieMZ0 pJ5mwMNC DT9EM4fp
DT9EM4fp oZAoGmlB JAKYGrEZ IZFfdR9P pJ5mwMNC
DT9EM4fp DT9EM4fp Sugkwky1 ksWAQXwV pjGcHwb2
DT9EM4fp DT9EM4fp qLguRON0 SpDuHoHu Ul82L21l
kRPimmAo oAXTA48Z eWF3Z9oR oAXTA48Z Hm424j9y
Ul82L21l VVyNccFD MA4m1aCK pJ5mwMNC JDd3ZkJr
AnagPUeG sA4YGD0Y JAKYGrEZ lRuaK1dP VVyNccFD
WApe3ag8 Mm47Wbmc HJ3buAFf aVvbsCnx VWukd67J
Fe73aIsU iJgm0B4Z Ul82L21l SVhdLX17 jD0xMvZP
AUClslB4 mH2JNFVh pJ5mwMNC C0wgciqm Ul82L21l
StH0ulwI pJ5mwMNC VVyNccFD JN1IIf8p Rsxr0kUJ
Mgd5HBZZ pJ5mwMNC VVyNccFD E12s2KTY mVm6wWad
Ul82L21l KBCLPIjr xljcJJcO pJ5mwMNC VVyNccFD
E12s2KTY HUrkc26x Ul82L21l KBCLPIjr pJ5mwMNC
VVyNccFD WApe3ag8 Mm47Wbmc HJ3buAFf aVvbsCnx
VVyNccFD wNAnQkse oTWOQmVl iJgm0B4Z Ul82L21l
Ul82L21l oAXTA48Z hIaodsKO Ul82L21l
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |