#10670. 「一本通 4.4 练习 1」Dis

「一本通 4.4 练习 1」Dis

[{"sectionTitle":"题目描述","type":"Text","text":"给出 nn 个点的一棵树,多次询问两点之间的最短距离。\r\n\r\n注意:边是双向的。","subType":"markdown"},{"sectionTitle":"输入格式","type":"Text","text":"第一行为两个整数 nnmmnn 表示点数,mm 表示询问次数;\r\n\r\n下来 n1n-1 行,每行三个整数 x,y,kx ,y, k,表示点 xx 和点 yy 之间存在一条边长度为 kk;\r\n\r\n再接下来 mm 行,每行两个整数 x,yx, y,表示询问点 xx 到点 yy 的最短距离。","subType":"markdown"},{"sectionTitle":"输出格式","type":"Text","text":"输出 mm 行。对于每次询问,输出一行。","subType":"markdown"},{"sectionTitle":"样例 1","type":"Sample","text":"","subType":"markdown","payload":["2 2\n1 2 100\n1 2\n2 1","100\n100"]},{"sectionTitle":"样例 2","type":"Sample","text":"","subType":"markdown","payload":["3 2\n1 2 10\n3 1 15\n1 2\n3 2","10\n25"]},{"sectionTitle":"数据范围与提示","type":"Text","text":"对于全部数据,$2\\le n\\le 10^4,1\\le m\\le 2\\times 10^4,0\\lt k\\le 100,1\\le x,y\\le n$。","subType":"markdown"}]