MWC '15 #2 P3: Breaking Ice

View as PDF

Submit solution

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

Problem type

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.