Formally, You Choose Three Integers
Time limit2sMemory limit512 MB
Decide whether array a can be turned into array b by repeatedly cyclically shifting an even-length contiguous block by an even number of positions.
- Level
Hard8 of 10
- Topics
- Math, Array, Combinatorics, Sorting
- Solved
- No attempts yet
Problem
You are given two arrays and of the same length .
You may perform the following operation on zero or more times:
Choose a contiguous subarray of even length and cyclically shift it by an even number of positions. Formally, you choose three integers (, is even, is even) and becomes , where denotes a slice with Python indexing. Precisely, it contains the elements with indices in the range in 0-indexing and in 1-indexing.
Is it possible to transform into ?
Input
The first line contains a single integer (), the length of and .
The second line contains integers (), the elements of .
The third line contains integers (), the elements of .
Output
Print 1 if it is possible to transform into , and 0 otherwise.