#P16901. [CCO 2026] Waterloo Tag

[CCO 2026] Waterloo Tag

Problem Description

Roger and Troy are playing a game of tag at the University of Waterloo. The University of Waterloo can be represented as NN buildings connected by MM sidewalks. The ii-th sidewalk connects buildings aia_i and bib_i, and is did_i metres long. There is at most 11 sidewalk between any pair of buildings. The sidewalks do not intersect (i.e. you can only move from one sidewalk to another at a building), and they might not lie on a plane (due to bridges and tunnels). Starting from any building, it is possible to reach any other building by walking along the sidewalks.

Roger starts the game of tag at building 11 and he can walk up to v1v_1 metres per second. Roger can also wait at a building or wait anywhere on a sidewalk. Roger will walk in a way that maximizes the duration of the game of tag.

Troy will pick a building xx and release a group of students at building xx. The students will spread out at v2v_2 metres per second along all sidewalks. The game of tag is over when Troy’s students reach Roger.

For each building xx, how long will the game of tag last?

Input Format

The first line of input will consist of 44 space-separated integers NN, MM, v1v_1, v2v_2 (2N20002 \le N \le 2000; N1M5000N - 1 \le M \le 5000; 1v1,v21001 \le v_1, v_2 \le 100).

The next MM lines each contain 33 integers, where the ii-th line contains integers aia_i, bib_i, did_i (1ai<biN1 \le a_i < b_i \le N; 1di100001 \le d_i \le 10000).

Output Format

Output N1N - 1 lines, where the ii-th line contains the duration of the game of tag in seconds if Troy releases a group of students at building i+1i + 1. You must output the duration as a fraction in simplest terms.

Note that an integer dd is a divisor of an integer qq if there is no remainder when qq is divided by dd. An integer zz is a common divisor of integers xx and yy if zz is a divisor of both xx and yy. A fraction x/yx/y is in simplest terms if yy is positive, and xx and yy do not have a common divisor greater than 11.

3 2 1 10
1 2 135
1 3 15

15/1
5/3
4 4 1 1
1 2 2
1 3 2
2 3 2
1 4 2
4/1
4/1
5/1

Hint

Explanation of Output for Sample Input 1

:::align{center} :::

For x=2x = 2, Roger should walk to building 33. After 1515 seconds, the students tag Roger at building 33 and the game of tag is over.

For x=3x = 3, Roger should walk towards building 22. After 5/35/3 seconds, the students tag Roger at the sidewalk between buildings 22 and 33 and the game of tag is over. Notice that Roger walked 1.6661.666\ldots metres and the students walked 15+1.66615 + 1.666\ldots metres.

Explanation of Output for Sample Input 2

:::align{center} :::

For x=2x = 2, Roger should walk to building 44.

For x=3x = 3, Roger should walk to building 44.

For x=4x = 4, Roger should walk to the centre of the sidewalk between buildings 22 and 33.

The following table shows how the 2525 available marks are distributed:

Marks Awarded Additional Constraints
33 marks N=3N = 3 and M=2M = 2.
N=3N = 3 and M=3M = 3.
77 marks v1=v2=1v_1 = v_2 = 1 and all sidewalks are 22 metres long (di=2d_i = 2).
N100N \le 100 and M200M \le 200.
55 marks None.