Sandwich

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You are about to make a delicious sandwich with N (1 \le N \le 100\,000) layers. You are going to put the sandwich together layer by layer. For each layer, you may choose to put it at either the bottom or the top of the currently made sandwich.

At the end of it all, you wish to observe your delicious sandwich – output the layers of the sandwich from top to bottom.

Input Specification

The integer N, followed by a sequence of 1s and 0s describing the process you followed creating the sandwich. The i-th character defines what you did with the i + 1 -th layer. 0 indicates you are putting the layer at the bottom of the sandwich, and 1 indicates you are putting it at the top.

Output Specification

The layers of the sandwich, in order from top to bottom.

Sample Input

5
00110

Sample Output

4
3
1
2
5

Comments


  • 0
    Xyene  commented on June 4, 2015, 9:22 p.m. edited

    I've lowered the time limit to 1s from 2s, as when this problem was created the DMOJ judging servers were significantly slower than they are now.

    All submissions have, of course, been rejudged.