Submission #1120922

#TimeUsernameProblemLanguageResultExecution timeMemory
1120922ngmtuanGrapevine (NOI22_grapevine)C++17
100 / 100
1763 ms112208 KiB
#include<bits/stdc++.h> #define VHnf9xgq soak(int #define tNooawcu u,v,w; #define u9jv6YVA lz[id]=0; #define lRxBq9el cout<<seek(u)<<'\n'; #define BVorPbYK i=1;i<=4*now;i++) #define QCcp5lxV CD(v,u); #define hr5WMDPO w) #define EnOkt7R1 dep[u]=dep[fa]+1; #define qjFWhBKr update(int #define gxgfKL7u ios::sync_with_stdio(false); #define ZSDfcLKi LOG=17; #define jnrjYcfA l,int #define BPbvx9wB if(in[dep[v]][x]<in[dep[v]][y]) #define XT7hV8B7 u,int #define BHSeYVC4 } #define Jc1emAnt get_cen(int #define NXmmccmM cin>>tp; #define PyqHy0y5 N=1e5+5; #define IQpW4O67 old=cost[{u,v}]; #define i01644s0 st[4*N*LOG],lz[4*N*LOG]; #define rNOTlHtS dfs(u,0,dep[u]); #define VBGC6xZg cost; #define hLYKBaqu push(id); #define ppZc8qHG long #define YHYYx07t fa,int #define pZC4LEXt dfs(int #define mbmqgnMc sz[u]=1; #define FRqPtQOl g[u].push_back(v); #define gDTbQRAl res; #define lECu5Z1W g[N]; #define jVoDcsHP apply(id,v); #define dFSSONiy qr) #define HrxYt78i soak(u); #define U5qjam2G tp; #define c7vgXAk0 apply(id<<1,lz[id]); #define GpDVw3Mk d) #define HVWPPrjt inf<<1; #define b17wZaxr apply(id<<1|1,lz[id]); #define kIfDjatN init() #define ACPR4xDV min(get(id<<1,l,mid,ql,qr),get(id<<1|1,mid+1,r,ql,qr)); #define On1lPkrW 0; #define VmrZJvot lz[id]+=v; #define NViWOTUy a-=inf; #define nfthxaj0 if(tp==2) #define OmlywsHJ CD(int #define ZZyZV33p { #define Iyo7H3HC on[N]; #define O13akPDD v=u;v;v=p[v]) #define fpdnpqZL st::update(1,1,now,in[dep[v]][x],out[dep[v]][x],w); #define lX5WJx3h while(q--) #define gQFoBAHP if(fa) #define NT4cT9WK cin>>n>>q; #define fWryZkvA return; #define E3o0d0FD seek(int #define Fk3GoSyB v) #define qlBwae6Z b=st::get(1,1,now,in[dep[v]][v],out[dep[v]][v]); #define GW9TQ9W6 u;cin>>u; #define bQgHQ2mA st::init(); #define XANOk0Dc cin.tie(0); #define AJuLkh9y namespace #define tp7kRRqF if(!del[v]&&v!=fa&&sz[v]>half) #define hCP8bOQo for(int #define wFpSjwSb i=1;i<n;i++){ #define ycMlKxN4 update(u,v,w-old); #define ZQU3nN0S st #define JD7CCx7m return #define FQI76mLQ p[u]=fa; #define S1RghDbk on[u]^=1; #define hK0BcWlP n,q; #define EsXlIyrJ v:g[u]) #define XZVxVabr x,int #define bToEhLTw fa) #define Wb8aFPfs x:cost) #define VFERPjRN del[N]; #define O0NMskd4 if(tp==1) #define Dg30dZVv get_sz(int #define jTaWVbEt for(;v;v=p[v]) #define GUuC3NED push(int #define DGnkS00q if(!del[v]) #define dCGu5DOq map<pair<int,int>,int> #define FaLLYLYb sz[N],dep[N],p[N]; #define c3KnZ0L6 ql,int #define ySCdPQvU half) #define CjWdF4Qk else #define Bo8yvh5n dfs(v,u,d); #define gTkJknBk if(!lz[id]) #define EYVcdWmV using #define rpjF1XHs v=(dep[x]<dep[y]?x:y); #define BWOSQ9oC main() #define plANrVo6 if(r<ql||qr<l) #define P25dpNEw inf=1e17; #define gG4Bqsfy swap(x,y); #define CZmn2Fvd if(!del[v]&&v!=fa) #define qpXbsSHA cost[{u,v}]=w; #define hK8yZbn6 void #define jnRiJibk res=inf; #define juZpH9Rj get_cen(v,u,half); #define egY6x3rA mid=(l+r)>>1; #define GH06tgoJ out[d][u]=now; #define LcWBW1kZ -1ll; #define amXxQ4yk id) #define fbRt3O3u update(x.first.first,x.first.second,x.second); #define K5rW9L7Z apply(int #define sM6AQx7p r,int #define PFP0nR93 CD(1,0); #define JkanSwHW update(id<<1|1,mid+1,r,ql,qr,v); #define t8SRmmSA get(int #define MLoGkcWM bool #define h2S0GkCs y,long #define T8Nj8Dq4 u; #define DEQMjYxo g[v].push_back(u); #define NxKX5PbJ u=get_cen(u,0,get_sz(u,0)>>1); #define l3CqhPL7 cin>>u>>v>>w; #define QH3sUS7i st[id]; #define C2CfnS1V sz[u]; #define dX3523KI st[i]=inf; #define QGVDgrbF st::update(1,1,now,in[dep[v]][u],in[dep[v]][u],(on[u]?-1:1)*inf); #define LQqZbOdI swap(u,v); #define w5bRh1s5 if(u>v) #define BQHKYxP6 in[LOG][N],out[LOG][N],now; #define RbKh4Hpo st[id]+=v; #define qOdwhMKt int #define O48AYxKX if(!on[u]) #define lhxGrEcR u) #define b0JFwdg0 qr,long #define uugi1GiG update(id<<1,l,mid,ql,qr,v); #define M42WN08Z vector<int> #define d814VTd9 if(ql<=l&&r<=qr) #define MPsX2yZs del[u]=1; #define ICUYy6P2 in[d][u]=++now; #define kO4RmeKD std; #define irBTvNmO const #define f4XMu86x if(res==inf) #define V8V6Iy7R id,int #define Vf7Jlumk id,long #define c0Rxm69I sz[u]+=get_sz(v,u); #define y1RYGiES a=st::get(1,1,now,in[dep[v]][u],in[dep[v]][u]); #define LRmMtCR0 for(auto #define HPn8PA0i st[id]=min(st[id<<1],st[id<<1|1]); #define yduO8snm res=min(res,a+b); EYVcdWmV AJuLkh9y kO4RmeKD irBTvNmO qOdwhMKt PyqHy0y5 irBTvNmO qOdwhMKt ZSDfcLKi irBTvNmO ppZc8qHG ppZc8qHG P25dpNEw qOdwhMKt hK0BcWlP M42WN08Z lECu5Z1W dCGu5DOq VBGC6xZg MLoGkcWM VFERPjRN qOdwhMKt FaLLYLYb qOdwhMKt BQHKYxP6 MLoGkcWM Iyo7H3HC AJuLkh9y ZQU3nN0S ZZyZV33p ppZc8qHG ppZc8qHG i01644s0 hK8yZbn6 kIfDjatN ZZyZV33p hCP8bOQo BVorPbYK dX3523KI BHSeYVC4 hK8yZbn6 K5rW9L7Z Vf7Jlumk ppZc8qHG Fk3GoSyB ZZyZV33p RbKh4Hpo VmrZJvot BHS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V33p BPbvx9wB gG4Bqsfy fpdnpqZL BHSeYVC4 BHSeYVC4 hK8yZbn6 VHnf9xgq lhxGrEcR ZZyZV33p S1RghDbk hCP8bOQo O13akPDD ZZyZV33p QGVDgrbF BHSeYVC4 BHSeYVC4 ppZc8qHG ppZc8qHG E3o0d0FD lhxGrEcR ZZyZV33p ppZc8qHG ppZc8qHG jnRiJibk hCP8bOQo O13akPDD ZZyZV33p ppZc8qHG ppZc8qHG y1RYGiES O48AYxKX NViWOTUy ppZc8qHG ppZc8qHG qlBwae6Z yduO8snm BHSeYVC4 f4XMu86x JD7CCx7m LcWBW1kZ JD7CCx7m gDTbQRAl BHSeYVC4 qOdwhMKt BWOSQ9oC ZZyZV33p gxgfKL7u XANOk0Dc NT4cT9WK hCP8bOQo wFpSjwSb qOdwhMKt tNooawcu l3CqhPL7 w5bRh1s5 LQqZbOdI FRqPtQOl DEQMjYxo qpXbsSHA BHSeYVC4 PFP0nR93 bQgHQ2mA LRmMtCR0 Wb8aFPfs ZZyZV33p fbRt3O3u BHSeYVC4 lX5WJx3h ZZyZV33p qOdwhMKt U5qjam2G NXmmccmM O0NMskd4 ZZyZV33p qOdwhMKt GW9TQ9W6 lRxBq9el BHSeYVC4 CjWdF4Qk nfthxaj0 ZZyZV33p qOdwhMKt GW9TQ9W6 HrxYt78i BHSeYVC4 CjWdF4Qk ZZyZV33p qOdwhMKt tNooawcu l3CqhPL7 w5bRh1s5 LQqZbOdI qOdwhMKt IQpW4O67 ycMlKxN4 qpXbsSHA BHSeYVC4 BHSeYVC4 JD7CCx7m On1lPkrW BHSeYVC4
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...