300962: CF180F. Mathematical Analysis Rocks!
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Mathematical Analysis Rocks!
题意翻译
题意简述: 有一个小组,里面有$n$个学生,每个学生按$1-n$进行编号,每个学生$i(1<=i<=n)$都有一个好朋友$p[i](1<=p[i]<=n)$ 准确的说,每个学生都是一个学生的最好的朋友。另一种说法是,所有的$p[i]$都是不一样的,但会出现一种可能情况,那就是存在学生$i$的好朋友是$i$,也就是它本身。 这个小组中每个人只会写一本课堂笔记,他们按照如下的算法去行动: - 第一天,每个学生复习自己的笔记 - 第二天,每个学生与他最好的朋友交换笔记本 因此,第二天,学生$p[i]$会复习第$i$个学生的笔记,第三天这个笔记将会给到学生$p[p[i]]$。以此类推,每个u而学生个每天都可以有一篇笔记去复习。 现在,你会得到两个序列来描述第三天和第四天的情况。 - $a_1,a_2,a_3...a_n$其中$a_i$指的是在第三天复习笔记时,拿到第$i$个学生笔记本的学生。 - $b_1,b_2,b_3...b_n$其中$b_i$指的是在第四天复习笔记时,拿到第$i$个学生笔记本的学生。 你不知道每个学生的最好朋友$p$,现在给你序列$a和b$,让你把这个序列$p$给求出来。 输入要求: 第一行包含一个整数$ n(1<=n<=10^5)$,表示的是小组内有$n$个学生。 第二行是一个长为$n$的序列$a[i]$。 第三行是一个长为$n$的序列$b[i]$. 输出格式: 一个长度为$n$的序列$p[1],p[2]...p[n]$这里保证答案唯一性。题目描述
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 $ .输入输出格式
输入格式
The first line contains integer $ n $ ( $ 1<=n<=10^{5} $ ) — 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 $ ).
输出格式
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.
输入输出样例
输入样例 #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