diff --git a/1dfroggereasy.py b/1dfroggereasy.py new file mode 100644 index 0000000..4ffaf88 --- /dev/null +++ b/1dfroggereasy.py @@ -0,0 +1,30 @@ +n, s, m = map(int, input().split()) +s -= 1 +board = list(map(int, input().split())) +shadow_board = [0] * n + + +def print_ending(ending, hops): + print(ending) + print(hops) + exit() + + +hops = 0 +while True: + if shadow_board[s] == 1: + print_ending("cycle", hops) + + shadow_board[s] = 1 + + if board[s] == m: + print_ending("magic", hops) + + if s + board[s] < 0: + print_ending("left", hops + 1) + + if n <= s + board[s]: + print_ending("right", hops + 1) + + s += board[s] + hops += 1