Submission #1008846

#TimeUsernameProblemLanguageResultExecution timeMemory
1008846vjudge1Patkice (COCI20_patkice)Cpython 3
50 / 50
12 ms3160 KiB
#https://dmoj.ca/problem/coci20c1p1 import sys def num_steps(i, j, grid): total = 0 while True: total = total + 1 if grid[i][j] == 'x': return total elif grid[i][j] == 'o' or grid[i][j] == '.': return 0 elif grid[i][j] == '^': i = i - 1 elif grid[i][j] == 'v': i = i + 1 elif grid[i][j] == '>': j = j + 1 elif grid[i][j] == '<': j = j - 1 r, c = map(int, input().split()) ocean = [list(input()) for _ in range(r)] for i in range(r): for j in range(c): if ocean[i][j] == 'o': east = num_steps(i, j + 1, ocean) west = num_steps(i, j - 1, ocean) north = num_steps(i - 1, j, ocean) south = num_steps(i + 1, j, ocean) winds = [east, north, south, west] winds_alphabet = ['E', 'N', 'S', 'W'] if any(winds): print(':)') max_steps = max(winds) for i in range(len(winds)): if winds [i] == 0: winds[i] = max_steps + 1 best_wind = '?' best_wind = winds_alphabet[winds.index(min(winds))] print(best_wind) else: print(':(') sys.exit()
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...