/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
N 人の木こり 1,2,\dots,N が斧を 1 個ずつ持っています。
全員が斧を池に落としてしまいました。
池に N 個の斧 1,2,\dots,N が沈んでいました。
各木こり i は「自分が持っていた斧は斧 A_i である」と主張しています。
一方、この池の女神は、各斧 i を持っていたのは木こり B_i であることを知っています。
N 人の木こり全員が本当のことを言っているかどうかを判定してください。
制約
- 1 \leq N \leq 100
- 1 \leq A_i \leq N
- 1 \leq B_i \leq N
- A_i \neq A_j\;(i \neq j)
- B_i \neq B_j\;(i \neq j)
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \dots A_N B_1 B_2 \dots B_N
出力
N 人の木こり全員が本当のことを言っているならば Yes を、そうでないならば No を出力せよ。
入力例 1
3 3 1 2 2 3 1
出力例 1
Yes
N 人の木こり全員が本当のことを言っています。
入力例 2
4 1 2 3 4 1 3 2 4
出力例 2
No
木こり 2,3 の 2 人は嘘をついています。
入力例 3
5 2 4 5 1 3 4 1 5 2 3
出力例 3
Yes
Score : 200 points
Problem Statement
N woodcutters 1, 2, \dots, N each have one axe.
All of them dropped their axes into a pond.
N axes 1, 2, \dots, N were found sunk in the pond.
Each woodcutter i claims that "I owned axe A_i."
On the other hand, the goddess of this pond knows that the woodcutter who owned axe i is woodcutter B_i.
Determine whether all N woodcutters are telling the truth.
Constraints
- 1 \leq N \leq 100
- 1 \leq A_i \leq N
- 1 \leq B_i \leq N
- A_i \neq A_j\;(i \neq j)
- B_i \neq B_j\;(i \neq j)
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \dots A_N B_1 B_2 \dots B_N
Output
Output Yes if all N woodcutters are telling the truth, and No otherwise.
Sample Input 1
3 3 1 2 2 3 1
Sample Output 1
Yes
All N woodcutters are telling the truth.
Sample Input 2
4 1 2 3 4 1 3 2 4
Sample Output 2
No
Woodcutters 2 and 3 are lying.
Sample Input 3
5 2 4 5 1 3 4 1 5 2 3
Sample Output 3
Yes