#6963. [ICPC 2024 Tehran R] Conference Rides
[ICPC 2024 Tehran R] Conference Rides
[ICPC 2024 Tehran R] Conference Rides
题目描述
There are $n$ attendees in a conference, numbered 1 through $n$. Each of the first $m$ attendees (numbered 1 through $m$) has a car to drive home after the event. The remaining $n - m$ attendees who do not have a car, are going to get a ride to their homes with the help of the first $m$ attendees. Each of the first $m$ attendees can pick up at most one other attendee (from attendees $m+1$ to $n$) and drive them to their house before going to their own home. You are given the distance matrix $D$ of the $n+1$ locations (the conference hall and $n$ attendees' homes). Find a way for attendees with cars to drive the attendees without cars home, such that the time it takes for all attendees to arrive at their homes is minimized. The distance matrix $D$ is an $(n+1) \times (n+1)$ matrix where $D[i][j]$ denotes the estimated time of transportation from location $i$ to location $j$. Location $i$ (for $1 \leq i \leq n$) denotes the home of the $i^{th}$ attendee and the conference hall is positioned at location $n+1$.输入格式
The input starts with a line containing two integers $n$ and $m$, ($1 \leq n \leq 500$ and $1 \leq m \leq n$). It is guaranteed that $2m \geq n$.The following lines specify the distance matrix , each containing integers. The number from the line of the input (for ) specifies (). It is guaranteed that for any , and also for , but is not necessarily equal to .
输出格式
In the first line of output, print the minimum time it takes for all attendees to arrive at their homes. In the next $m$ lines, each line $i$ (for $1 \leq i \leq m$) should contain a single non-negative integer $t_i$, denoting the driving schedule of the $i^{th}$ attendee. If $t_i = 0$, the attendee drives directly to their home without picking up any other attendees. Otherwise ($t_i > 0$), the $i^{th}$ attendee picks up the attendee $t_i$ and takes them to their home before driving to their own home. Each attendee must be transferred by exactly one car.3 2
0 1 1 2
2 0 1 3
4 2 0 4
4 3 2 0
4
0
3