{"trustable":true,"sections":[{"title":"题目描述","value":{"format":"MD","content":"你知道黑暗城堡有 $N$ 个房间,$M$ 条可以制造的双向通道,以及每条通道的长度。 \r\n\r\n城堡是树形的并且满足下面的条件:\r\n\r\n设 $D_i$ 为如果所有的通道都被修建,第 $i$ 号房间与第 $1$ 号房间的最短路径长度;\r\n\r\n而 $S_i$ 为实际修建的树形城堡中第 $i$ 号房间与第 $1$ 号房间的路径长度;\r\n\r\n要求对于所有整数 $i$ ($1\\le i\\le N$),有 $S_i\u003d D_i$ 成立。\r\n\r\n你想知道有多少种不同的城堡修建方案。当然,你只需要输出答案对 $2^{31} -1$ 取模之后的结果就行了。\r\n"}},{"title":"输入格式","value":{"format":"MD","content":"第一行为两个由空格隔开的整数 $N, M$;\r\n\r\n第二行到第 $M+1$ 行为 $3$ 个由空格隔开的整数 $x, y, l$:表示 $x$ 号房间与 $y$ 号房间之间的通道长度为 $l$。"}},{"title":"输出格式","value":{"format":"MD","content":"一个整数:不同的城堡修建方案数对 $2^{31} -1$ 取模之后的结果。"}},{"title":"样例","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4 6\n1 2 1\n1 3 2\n1 4 3\n2 3 1\n2 4 2\n3 4 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n一共有 $4$ 个房间,$6$ 条道路,其中 $1$ 号和 $2$ 号,$1$ 号和 $3$ 号,$1$ 号和 $4$ 号,$2$ 号和 $3$ 号,$2$ 号和 $4$ 号,$3$ 号和 $4$ 号房间之间的通道长度分别为 $1$,$2$,$3$,$1$,$2$,$1$。\n\n而不同的城堡修建方案数对 $2^{31} -1$ 取模之后的结果为 $6$。"}},{"title":"数据范围与提示","value":{"format":"MD","content":"对于全部数据,$ 1\\le N\\le 1000 $,$ 1\\le M\\le \\frac{N(N-1)}{2} $,$1\\le l\\le 200$。"}}]}