1-D Frogger (Easy)
This commit is contained in:
30
1dfroggereasy.py
Normal file
30
1dfroggereasy.py
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user