AT_abc461_b.The Honest Woodcutters

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

NN woodcutters 1,2,…,N1, 2, \dots, N each have one axe. All of them dropped their axes into a pond.
NN axes 1,2,…,N1, 2, \dots, N were found sunk in the pond.
Each woodcutter ii claims that "I owned axe AiA_i."
On the other hand, the goddess of this pond knows that the woodcutter who owned axe ii is woodcutter BiB_i.

Determine whether all NN woodcutters are telling the truth.

NN 位伐木工 1,2,…,N1, 2, \dots, N 各自拥有一把斧头。他们所有人都将斧头掉进了池塘。
池塘中打捞出了 NN 把斧头,编号为 1,2,…,N1, 2, \dots, N。
每位伐木工 ii 声称:“我拥有斧头 AiA_i。”
另一方面,这座池塘的女神知道:拥有斧头 ii 的伐木工是伐木工 BiB_i。

判断这 NN 位伐木工是否全部说了真话。

输入格式

The input is given from Standard Input in the following format:

NN
A1A_1 A2A_2 …\dots ANA_N
B1B_1 B2B_2 …\dots BNB_N

输入从标准输入中按以下格式给出:

NN
A1A_1 A2A_2 …\dots ANA_N
B1B_1 B2B_2 …\dots BNB_N

输出格式

Output Yes if all NN woodcutters are telling the truth, and No otherwise.

如果所有 NN 位伐木工都在说真话,则输出 Yes,否则输出 No。

输入输出样例

  • 输入#1

    3
    3 1 2
    2 3 1

    输出#1

    Yes
  • 输入#2

    4
    1 2 3 4
    1 3 2 4

    输出#2

    No
  • 输入#3

    5
    2 4 5 1 3
    4 1 5 2 3

    输出#3

    Yes

说明/提示

Sample 1 Explanation:
All NN woodcutters are telling the truth.

Sample 2 Explanation:
Woodcutters 22 and 33 are lying.

Constraints

  • 1≤N≤1001 \leq N \leq 100
  • 1≤Ai≤N1 \leq A_i \leq N
  • 1≤Bi≤N1 \leq B_i \leq N
  • Ai≠Aj  (i≠j)A_i \neq A_j\;(i \neq j)
  • Bi≠Bj  (i≠j)B_i \neq B_j\;(i \neq j)
  • All input values are integers.

样例 1 解释:
所有 NN 名伐木工都在说真话。

样例 2 解释:
伐木工 22 和 33 在说谎。

约束条件

  • 1≤N≤1001 \leq N \leq 100
  • 1≤Ai≤N1 \leq A_i \leq N
  • 1≤Bi≤N1 \leq B_i \leq N
  • Ai≠Aj  (i≠j)A_i \neq A_j\;(i \neq j)
  • Bi≠Bj  (i≠j)B_i \neq B_j\;(i \neq j)
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页