Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- directions_moves = {'right': [], 'left': [], 'up': [], 'down': []}
- max_eggs = float('-inf')
- max_direction = ''
- rows = int(input())
- matrix = []
- bunny_row, bunny_col = None, None
- for row in range(rows):
- current_line = input().split()
- matrix.append(current_line)
- for col in range(rows):
- if matrix[row][col] == "B":
- bunny_row, bunny_col = row, col
- for direction in ["right", "left", "up", "down"]:
- current_direction = direction
- current_eggs = 0
- if direction == 'up':
- for r in range(bunny_row - 1, -1, -1):
- if matrix[r][bunny_col] != 'X':
- current_eggs += int(matrix[r][bunny_col])
- directions_moves[current_direction].append((r, bunny_col))
- else:
- break
- elif direction == "right":
- for c in range(bunny_col + 1, rows):
- if matrix[bunny_row][c] != 'X':
- current_eggs += int(matrix[bunny_row][c])
- directions_moves[current_direction].append((bunny_row, c))
- else:
- break
- elif direction == "left":
- for c in range(bunny_col - 1, -1, -1):
- if matrix[bunny_row][c] != 'X':
- current_eggs += int(matrix[bunny_row][c])
- directions_moves[current_direction].append((bunny_row, c))
- else:
- break
- elif direction == "down":
- for r in range(bunny_row + 1, rows):
- if matrix[r][bunny_col] != 'X':
- current_eggs += int(matrix[r][bunny_col])
- directions_moves[current_direction].append((r, bunny_col))
- else:
- break
- if current_eggs > max_eggs and directions_moves[current_direction]:
- max_eggs = current_eggs
- max_direction = current_direction
- if max_direction:
- print(max_direction)
- for idx_r, idx_c in directions_moves[max_direction]:
- print(f"[{idx_r}, {idx_c}]")
- print(max_eggs)
Advertisement
Advertisement
Advertisement
RAW Paste Data
Copied
Advertisement