#include #include #define WIDTH 1000 #define SIZE WIDTH*101 #define PARENT WIDTH-1 #define ROOT 1 int N_nodes; int N_merchants; int N_N[SIZE][WIDTH*2]; int c; long tax[SIZE]; long maxdepth,taxsum; int dep[WIDTH][SIZE]; void push_N_N(u,v){ N_N[u][++N_N[u][0]]=v; N_N[v][++N_N[v][0]]=u; } void order_nodes(r,parent){ int i,j,child; c++; if(maxdepth1;d--) for (i=1;i<=dep[d][0];i++) tax[N_N[dep[d][i]][PARENT]]+=tax[dep[d][i]]; } int main(){ int i,j,k, u,v,mer,lca_node; scanf("%d",&N_nodes); for (i=1;i