Skip to content

Editorial for Tuyến xe

Tuyến xe

Problem code: olpicpc141c28 Group: Uncategorized Points: 100 pointspartial
Limits
1.0 s, 256 MB
AC rate
25.0%
Solvers
2
Read the editorial only when you are stuck, and do not copy code from it. Please respect the problem author and the editorialist: submitting an official solution before solving the problem yourself is a bannable offence.

Nhật xét 1: Cần xử lý với trường hợp đa đồ thị, chỉ lưu lại cạnh nhỏ nhất. Vì vậy có tối đa n^2 cạnh.

Nhật xét 2: Đường đi ngắn nhất không thể chứa chu trình, vì vậy chỉ cần sử dụng tối đa n-1 tuyến xe. Nếu k \ge n thì đáp án giống với trường hợp k=n-1.

Gọi dp[d][x][y] là thời gian ngắn nhất di chuyển từ đỉnh x đến đỉnh y sử dụng tối đa d tuyến xe. Tiến hành duyệt qua các cạnh [z,y] với trọng số w[z][y] để cập nhật:

\displaystyle dp[d][x][y] = \min\{dp[d-1][x][z]+w[z][y]\}

Độ phức tạp: O(n^4).

Comments