CF180F.Mathematical Analysis Rocks!
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
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 n. Each student i (1 ≤ i ≤ n) has a best friend p[i] (1 ≤ p[i] ≤ n). In fact, each student is a best friend of exactly one student. In other words, all p[i] are different. It is possible that the group also has some really "special individuals" for who 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] (1 ≤ i ≤ n) studies the i-th student's notes, on the third day the notes go to student 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:
- _a_1, _a_2, ..., a__n, where a__i means the student who gets the i-th student's notebook on the third day of revising;
- _b_1, _b_2, ..., b__n, where b__i means the student who gets the i-th student's notebook on the fourth day of revising.
You do not know array p, that is you do not know who is the best friend to who. Write a program that finds p by the given sequences a and b.
199班的学生们听课记录写得一塌糊涂。现在数学分析考试即将来临,必须尽快(即迅速)采取措施。我们把该班学生从1到n编号。每个学生i(1 ≤ i ≤ n)有一位最好的朋友p[i](1 ≤ p[i] ≤ n)。事实上,每个学生恰好被唯一一个学生视为最好的朋友。换言之,所有p[i]互不相同。可能存在一些真正“特别的个体”,即满足i = p[i]的学生。
每位学生恰好撰写了一本数学分析课堂笔记。已知学生们约定按如下算法进行复习:
- 复习第一天,每位学生学习自己撰写的数学分析笔记;
- 此后每一天清晨,每位学生将自己的笔记本交给其最好的朋友,并从那位视自己为最好朋友的学生手中接过一本笔记本。
因此,在复习第二天,学生p[i](1 ≤ i ≤ n)学习第i位学生的笔记;在第三天,这些笔记传至学生p[p[i]],依此类推。由于男生友谊的某些特性(见上文第一段),每天每位学生都恰好拥有一本笔记可供学习。
现给出描述复习第三天和第四天情况的两个序列:
- a1, a2, ..., an,其中ai表示在复习第三天获得第i位学生笔记的学生;
- b1, b2, ..., bn,其中bi表示在复习第四天获得第i位学生笔记的学生。
你并不知道数组p(即不知道谁是谁的最好朋友)。请编写一个程序,根据给定的序列a和b求出p。
输入格式
The first line contains integer n (1 ≤ n ≤ 105) — the number of students in the group. The second line contains sequence of different integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ n). The third line contains the sequence of different integers _b_1, _b_2, ..., b__n (1 ≤ b__i ≤ n).
第一行包含一个整数 n(1≤n≤105)—— 表示小组中的学生人数。
第二行包含一个由互不相同的整数构成的序列 a1,a2,…,an(1≤ai≤n)。
第三行包含一个由互不相同的整数构成的序列 b1,b2,…,bn(1≤bi≤n)。
输出格式
Print sequence n of different integers p[1], p[2], ..., p[n] (1 ≤ p[i] ≤ n). It is guaranteed that the solution exists and that it is unique.
输出一个长度为 n 的不同整数序列 p[1], p[2], …, p[n](其中 1 ≤ p[i] ≤ n)。保证解存在且唯一。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?