The Prom
N people stand in a line with IDs from 1 to N to enter their high school's prom.
Given a string S, where '0' indicates girls and '1' indicates a boy. When a boy arrives, he pairs up with the girl standing immediately ahead him in line. They then leave the line to go to the dance floor.
To ensure that everyone at the prom gets one dance, each boy finds the ID of the girl who he danced with. If a boy cannot go on a date, the answer is -1.
Complete the function solve. This function takes the following 2 parameters:
N: Represents the number of peopleS: Represents the binary string denoting the genders
Input format for custom testing
Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code.
Output Format
Print space-separated integers denoting the IDs of the girls.
Note:
Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.
Limits
- Time Limit: 1.0 sec(s) for each input file
- Memory Limit: 256 MB
- Source Limit: 1024 KB
Scoring
Score is assigned if any testcase passes
1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
- 1 ≤ N ≤ 10^5
- S[i] ∈ {0, 1} ∀ i ∈ [1,N]