#P10919. 运输规划

    ID: 12250 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>O2优化二分图树链剖分笛卡尔树

运输规划

Background

You need to plan truck transportation routes. To help you solve the problem better, please read the statement carefully.

Problem Description

There are nn cities. For any 1<in1 < i \leq n, there is a bidirectional road between city ii and city i1i-1. Each city has a truck height limit hih_i, meaning only trucks with height less than or equal to hih_i can pass through this city. Now there are mm cities S1,S2,...,SmS_{1}, S_{2}, ..., S_{m}, each having exactly one transportation task. The task requires the truck with index ii and height hSih_{S_{i}} to depart from city SiS_{i} and arrive at any city that has an airport. There are mm cities with airports, which are T1,T2,...,TmT_{1}, T_{2}, ..., T_{m}. 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 cic_i denote the truck index that arrives at the airport located in city TiT_i. Let the array F={c1,c2,...,cm}F = \{c_1, c_2, ..., c_m\}. Please minimize the lexicographic order of FF and output FF.

We define two arrays A,BA, B of length lenlen. AA is lexicographically smaller than BB if and only if there exists 0i<len0 \leq i < len such that for all 1ji1 \leq j \leq i, Aj=BjA_j = B_j, and Ai+1<Bi+1A_{i+1} < B_{i+1}.

The testdata guarantees that a solution exists. It also guarantees that all hih_i are pairwise distinct, all TiT_i are pairwise distinct, and all SiS_i are pairwise distinct. However, it may happen that there exist i,ji, j such that Si=TjS_i = T_j.

Input Format

The first line contains two integers n,mn, m.

The next line contains nn integers h1,h2,...,hnh_1, h_2, ..., h_n.

The next line contains mm integers S1,S2,...,SmS_{1}, S_{2}, ..., S_{m}.

The next line contains mm integers T1,T2,...,TmT_{1}, T_{2}, ..., T_{m}.

Output Format

Output one line with mm integers representing FF.

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
11 n,m50n, m \leq 50 1010
22 For any 1<in1 < i \leq n, hi<hi1h_i < h_{i-1} 2525
33 n,m103n, m \leq 10^3
44 No special property 4040

For 100%100\% of the testdata, it is guaranteed that 1mn2×1051 \leq m \leq n \leq 2 \times 10^5 and 0<hi1090 < h_i \leq 10^9.

Translated by ChatGPT 5