Score : 300 points
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.
Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:
Input is given from Standard Input in the following format:
N a_1 a_2 .. a_N b_1 b_2 .. b_N
If we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes
; otherwise, print No
.
3 1 2 3 5 2 2
Yes
For example, we can perform three operations as follows to do our job:
5 3 1 4 1 5 2 7 1 8 2
No
5 2 7 1 8 2 3 1 4 1 5
No