atcoder#ARC136B. [ARC136B] Triple Shift
[ARC136B] Triple Shift
Score : points
Problem Statement
You are given integer sequences of length each: and .
You can repeat the following operation any number of times.
- Choose an integer () and let be the current values of , respectively. Then, replace the values of with , respectively.
Determine whether it is possible to make equal .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to make equal , print Yes
; otherwise, print No
.
4
3 1 4 5
4 1 5 3
Yes
We should do the following.
- Initially, we have .
- Do the operation with , making .
- Do the operation with , making .
- Do the operation with , making .
3
1 2 2
2 1 2
Yes
3
1 2 3
2 3 4
No