问题 H: traffic

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:3 通过:3

题目描述

Alice's country has nnn cities, and these nnn cities are connected by n+1n+1n+1 channels. If a channel is opened, residents on one end can reach the other end through this channel. There are a total of T+1T+1T+1 days (from day 000 to day TTT), and the cost of opening the iii-th channel on the jjj-th day is given by the expression ai×j+bia_i \times j + b_iai×j+bi. The total cost for a specific day is the sum of costs of all the channels opened on that day.

Alice needs to determine which channels to open each day to ensure that residents can reach any other city through the opened channels every day while minimizing the total cost. Can you help her?

输入格式

The first line contains two integers nnn and T(2≤n,T≤105)T (2 \leq n, T \leq 10^5)T(2n,T105), representing the number of cities and the total number of days.
The next n+1n+1n+1 lines (from 222nd to (n+2)(n+2)(n+2)-th) each contain four integers ui,vi,ai,bi(1≤ui,vi≤n,0≤ai,bi≤108)u_i, v_i, a_i, b_i(1 \leq u_i, v_i \leq n, 0 \leq a_i,b_i \leq 10^8)ui,vi,ai,bi(1ui,vin,0ai,bi108), representing a channel between cities uiu_iui and viv_ivi. The cost of opening this channel on the jjj-th day is ai×j+bia_i \times j + b_iai×j+bi.
It is guaranteed that there are no self-loops, but there may be multiple edges between the same pair of vertices.

输出格式

Output T+1T+1T+1 lines, each containing an integer, representing the minimum cost for each of the days from 000 to TTT.

输入样例 复制

5 3
1 2 3 1
1 3 1 2
2 3 1 3
3 4 1 1
3 5 1 2
4 5 1 3

输出样例 复制

6
12
16
20