cswork / OAOpen practice workspace

HackerearthOA #2

The Prom

Estimated EasyJudge-ready

Topics (AI-labelled)Stacks & Heaps

Process the queue from left to right. 0 represents a girl and 1 represents a boy. Each boy dances with the nearest unpaired girl currently standing in front of him, and both leave the queue. If there is no girl to pair with, record -1. Output the indices of the paired girls in the order the boys appear.

Input

The input contains N and a 01 string of length N, 1≤N≤100000.

Output

Output the girl index for each boy; output -1 when there is no girl to pair with, and output an empty line if the result is empty.

Example 1

Input:

3
011

Output:

1 -1

Example 2

Input:

11
10001111110

Output:

-1 4 3 2 -1 -1 -1

Example 3

Input:

7
0000100

Output:

4

Editorial

Loading solution…