MWC '15 #2 P3: Breaking Ice

View as PDF

Submit solution

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

Author:
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

4
L L R R

Sample Output

Fell at 3

Comments


  • 0
    gavin_chen  commented on Jan. 14, 2023, 1:51 a.m.

    may soeone explain why y code ainbt worling?