MWC '15 #2 P3: Breaking Ice

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

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

Salarios77 is walking on ice, however it's getting warm and after he does every step the ice breaks! You are given Salarios77's walking routine, figure out if (and when) Salarios77 will step on the same block twice and fall into the water.

Input Specification

The first line will contain integer N (number of steps, 1 \le N \le 1000).
Second line will be followed by N letters indicating each respective move: U (up), D (down), R (right), or L (left).

Output Specification

You either output: Fell at N, or if Salarios77 does not fall then Safe!.

Sample Input


Sample Output

Fell at 3


  • 1
    Jeffmagma  commented on March 31, 2016, 5:36 p.m.

    I think there is an extra space beside the R in the Input Specifications

    • 1
      MathBunny123  commented on March 31, 2016, 7:15 p.m.

      Good catch! Fixed.