Tree Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 18205 Accepted: 5951 Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an…
Tree Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 24253 Accepted: 8060 Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an…
Give a tree with n vertices,each edge has a length(positive integer less than 1001).Define dist(u,v)=The min distance between node u and v. Give an integer k,for every pair (u,v) of vertices is called valid if and only if dist(u,v) not exceed k. Writ…
给定一棵有n个点的树 询问树上距离为k的点对是否存在. AC code: #include<bits/stdc++.h> using namespace std; const int MAXN = 10005; const int MAXM = 105; const int MAXK = 10000005; int n, m, q[MAXM]; int fir[MAXN], to[MAXN<<1], nxt[MAXN<<1], wt[MAXN<<1], cn…
Tree Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16172 Accepted: 5272 Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. …
#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #define N 40005 #define M 80005 #define LL long long using namespace std; const int INF = 0x3f3f3f3f; int ver[M],edge[M],head[N],Next[M]; int n,m,tot,r…