CF180F.Mathematical Analysis Rocks!

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Students of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the students of the group from 1 to nn . Each student ii ( 1<=i<=n1<=i<=n ) has a best friend p[i]p[i] ( 1<=p[i]<=n1<=p[i]<=n ). In fact, each student is a best friend of exactly one student. In other words, all p[i]p[i] are different. It is possible that the group also has some really "special individuals" for who i=p[i]i=p[i] .

Each student wrote exactly one notebook of lecture notes. We know that the students agreed to act by the following algorithm:

  • on the first day of revising each student studies his own Mathematical Analysis notes,
  • in the morning of each following day each student gives the notebook to his best friend and takes a notebook from the student who calls him the best friend.

Thus, on the second day the student p[i]p[i] ( 1<=i<=n1<=i<=n ) studies the ii -th student's notes, on the third day the notes go to student p[p[i]]p[p[i]] and so on. Due to some characteristics of the boys' friendship (see paragraph 1), each day each student has exactly one notebook to study.

You are given two sequences that describe the situation on the third and fourth days of revising:

  • a1,a2,...,ana_{1},a_{2},...,a_{n} , where aia_{i} means the student who gets the ii -th student's notebook on the third day of revising;
  • b1,b2,...,bnb_{1},b_{2},...,b_{n} , where bib_{i} means the student who gets the ii -th student's notebook on the fourth day of revising.

You do not know array pp , that is you do not know who is the best friend to who. Write a program that finds pp by the given sequences aa and bb .

输入格式

The first line contains integer nn ( 1<=n<=1051<=n<=10^{5} ) — the number of students in the group. The second line contains sequence of different integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=n1<=a_{i}<=n ). The third line contains the sequence of different integers b1,b2,...,bnb_{1},b_{2},...,b_{n} ( 1<=bi<=n1<=b_{i}<=n ).

输出格式

Print sequence nn of different integers p[1],p[2],...,p[n]p[1],p[2],...,p[n] ( 1<=p[i]<=n1<=p[i]<=n ). It is guaranteed that the solution exists and that it is unique.

输入输出样例

  • 输入#1

    4
    2 1 4 3
    3 4 2 1
    

    输出#1

    4 3 1 2 
  • 输入#2

    5
    5 2 3 1 4
    1 3 2 4 5
    

    输出#2

    4 3 2 5 1 
  • 输入#3

    2
    1 2
    2 1
    

    输出#3

    2 1 
首页