AT_abc461_b.The Honest Woodcutters
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
N woodcutters 1,2,…,N each have one axe. All of them dropped their axes into a pond.
N axes 1,2,…,N were found sunk in the pond.
Each woodcutter i claims that "I owned axe Ai."
On the other hand, the goddess of this pond knows that the woodcutter who owned axe i is woodcutter Bi.
Determine whether all N woodcutters are telling the truth.
N 位伐木工 1,2,…,N 各自拥有一把斧头。他们所有人都将斧头掉进了池塘。
池塘中打捞出了 N 把斧头,编号为 1,2,…,N。
每位伐木工 i 声称:“我拥有斧头 Ai。”
另一方面,这座池塘的女神知道:拥有斧头 i 的伐木工是伐木工 Bi。
判断这 N 位伐木工是否全部说了真话。
输入格式
The input is given from Standard Input in the following format:
N
A1 A2 … AN
B1 B2 … BN
输入从标准输入中按以下格式给出:
N
A1 A2 … AN
B1 B2 … BN
输出格式
Output Yes if all N woodcutters are telling the truth, and No otherwise.
如果所有 N 位伐木工都在说真话,则输出 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 N woodcutters are telling the truth.
Sample 2 Explanation:
Woodcutters 2 and 3 are lying.
Constraints
- 1≤N≤100
- 1≤Ai≤N
- 1≤Bi≤N
- Ai=Aj(i=j)
- Bi=Bj(i=j)
- All input values are integers.
样例 1 解释:
所有 N 名伐木工都在说真话。
样例 2 解释:
伐木工 2 和 3 在说谎。
约束条件
- 1≤N≤100
- 1≤Ai≤N
- 1≤Bi≤N
- Ai=Aj(i=j)
- Bi=Bj(i=j)
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?