loj#P184. 单位蒙日矩阵乘法
单位蒙日矩阵乘法
Description
For a permutation of order , let be a square matrix, and , all indices are -indexed.
For two matrices , we define the distance product be $(A\otimes B)_{i,j} = \min_k \left(A_{i,k}+B_{k,j}\right)$.
You are given two permutations of order , it can be shown that there exists a unique permutation satisfying , please compute .
Input
The first line contains one positive integer .
The rest two lines contain positive integers for each line, representing the permutations respectively.
Output
Please output integers in one line, representing the permutation .
3
1 3 2
2 1 3
2 3 1
Limits And Hints
For of the dataset, it's guaranteed that .
For of the dataset, it's guaranteed that , and are permutations.