Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
directions = { "up": lambda row, col: (row - 1, col), "down": lambda row, col: (row + 1, col), "left": lambda row, col: (row, col - 1), "right": lambda row, col: (row, col + 1), } size = int(input()) matrix = [] bunny_row = 0 bunny_col = 0 for row in range(size): inner_list = input().split() matrix.append(inner_list) for col in range(size): if inner_list[col] == "B": bunny_row, bunny_col = row, col best_dir = "" best_path = [] best_sum = float("-inf") for direction, moving in directions.items(): current_row, current_col = bunny_row, bunny_col path = [] current_sum = 0 while True: current_row, current_col = moving(current_row, current_col) if current_row < 0 or current_col < 0 or current_row >= size or current_col >= size: break if matrix[current_row][current_col] == "X": break path.append([current_row, current_col]) current_sum += int(matrix[current_row][current_col]) if current_sum > best_sum and path: best_sum = current_sum best_dir = direction best_path = path print(best_dir) for path in best_path: print(path) print(best_sum)
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)