#d11405. Nearest Opposite Parity
Nearest Opposite Parity
Nearest Opposite Parity
Problem Description
Given an array of length indexed from . From position you can move to position (if ) or (if ).
For each position (), find the minimum number of steps to reach some position such that . If no such position exists, output -1.
Input Format
The first line contains an integer (), the length of the array.
The second line contains integers (), the given array.
Output Format
Output one line containing integers, where the -th integer is the answer starting from position .
Sample Input
10
4 5 7 6 7 5 4 4 6 4
Sample Output
1 1 1 2 -1 1 1 3 1 1