HackerearthOA #2
The Prom
估计简单可在线判题
考点(AI 标注)单调栈与堆
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.
输入格式
The input contains N and a 01 string of length N, 1≤N≤100000.
输出格式
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.
样例 1
输入:
3
011
输出:
1 -1
样例 2
输入:
11
10001111110
输出:
-1 4 3 2 -1 -1 -1
样例 3
输入:
7
0000100
输出:
4