#P10919. 运输规划
运输规划
Background
You need to plan truck transportation routes. To help you solve the problem better, please read the statement carefully.
Problem Description
There are cities. For any , there is a bidirectional road between city and city . Each city has a truck height limit , meaning only trucks with height less than or equal to can pass through this city. Now there are cities , each having exactly one transportation task. The task requires the truck with index and height to depart from city and arrive at any city that has an airport. There are cities with airports, which are . For a valid transportation plan, it must be guaranteed that each truck arrives at an airport and each airport has exactly one truck arriving. An airport can be passed through by multiple trucks at the same time. Note that if you cannot pass through a city, then you also cannot arrive at that city.
Let denote the truck index that arrives at the airport located in city . Let the array . Please minimize the lexicographic order of and output .
We define two arrays of length . is lexicographically smaller than if and only if there exists such that for all , , and .
The testdata guarantees that a solution exists. It also guarantees that all are pairwise distinct, all are pairwise distinct, and all are pairwise distinct. However, it may happen that there exist such that .
Input Format
The first line contains two integers .
The next line contains integers .
The next line contains integers .
The next line contains integers .
Output Format
Output one line with integers representing .
10 3
1 2 3 5 4 10 8 6 7 9
1 2 8
6 10 3
1 3 2
20 5
12 13 14 15 16 17 18 19 20 22 21 30 29 28 27 26 23 24 25 1
1 20 2 5 3
10 12 11 9 13
1 2 3 4 5
Hint
This problem uses bundled tests.
| Subtask ID | Special Property | Score |
|---|---|---|
| For any , | ||
| No special property |
For of the testdata, it is guaranteed that and .
Translated by ChatGPT 5