树上差分

xiaoxiao2025-08-30  7

bool check(int x) {     int cnt=0,dist=0;     memset(tmp,0,sizeof(tmp));     for(int i=1; i<=m; i++)     {         if(Q[i].Dis > x)         {             tmp[Q[i].s]++;             tmp[Q[i].t]++;             tmp[Q[i].lca] -= 2;             dist=chkmax(dist,Q[i].Dis-x);             cnt++;         }     }     if(!cnt) return true;     for(int i=n; i>1; i--)         tmp[grand[kth[i]][0]] += tmp[kth[i]];     for(int i=2; i<=n; i++)         if(tmp[i]==cnt && prev[i]>=dist)             return true;     return false; }  

转载请注明原文地址: https://www.6miu.com/read-5035477.html

最新回复(0)