Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

IOI Kyrgyzstan Qualification Round 2019

Bishkek, April 2019

Task B. Biased Path


Time limit: 2 seconds
Memory limit: 256MB

You are given an undirected graph with N vertices and M edges. The graph may contain loops and
multiple edges between any two vertices. Each edge of the graph has a positive integer length. Find the
path with the shortest length from the given vertex S to the given vertex T such that the number of
vertices in the path is divisible by 2019.

Input
First line of the input contains four integers: N (0 < N ≤ 50), M (0 ≤ M ≤ 2000), S, T (0 < S, T ≤ N ).
Each of the following M lines describes an edge using three integers: X, Y , L, where X and Y are vertices
that are connected by the edge and L (0 < L ≤ 1000) is the length of the edge.

Output
If no solution exists, then output "Mumkun emes" (without quotes). Otherwise, output the shortest
distance between S and T that satisfies the requirements stated above.

Grading
Solutions that work correctly for N < 10, M < 50 will receive 10 points.

Examples
Input Output
1 0 1 1 Mumkun emes
1 1 1 1 20180
1 1 10
2 1 1 2 40370
1 2 10
3 2 1 3 3017
1 2 1
3 2 1000
4 5 1 4 4064
1 2 10
1 2 30
2 3 1
1 4 10
3 4 100

Note
In the second example the path is (1 → 1 → . . . → 1) where 1 appears 2019 times.
In the third example the path is (1 → 2 → 1 → . . . → 2) where 1 and 2 appear 2019 times each.

Page 1 of 1

You might also like