Petrol stations
시간 제한3.5초메모리 제한2048 MB
트리 위 모든 순서쌍 도시 사이를 달리는 차가 다음 도시에 도달할 연료가 없을 때만 가득 주유한다고 할 때, 각 도시의 주유소에서 멈춘 차의 수를 구한다.
문제
The Czech highway network consists of cities and roads with known lengths in kilometers. We know that there exists exactly one path between each pair of cities. Furthermore, there exists exactly one petrol station in each of the cities and nowhere else.
One day, several people decided to go on a car trip. There were a total of cars traveling. Strangely, it holds that for each ordered pair of cities there was exactly one car going from the city to the city , traveling alongside the only path between these cities. Since everyone in Czechia uses Škoda cars, every car has the same fuel tank capacity of liters and they steadily consume one liter of petrol per kilometer traveled. Before departure, the fuel tank of each car is full. Furthermore, the Czechs are quite predictable. Due to their laziness, they refuel only when they don't have enough petrol to reach the next city (entering a city with an empty tank is still possible). Once they are forced to stop at a petrol station, they always fill their tank fully.
The Czech tax authority would like to know how many cars stopped at each petrol station during the day. Given this predictable behavior, you should be able to compute it easily.
입력
The first line of the input contains two space-separated integers and — the number of cities and the capacity of the fuel tank of each car. The following lines describe roads. Each of them contains three space-separated integers , and , where and are indices of cities connected by the -th road and is the length of this road in kilometers. Cities are numbered from to . It is guaranteed that for every pair of cities, there exists exactly one path between them.
출력
You should output lines, which should contain the number of cars stopping at the petrol station in each city, ordered from city to city .
제한
- (for each such that )