CF1765K.Torus Path

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a square grid with nn rows and nn columns, where each cell has a non-negative integer written in it. There is a chip initially placed at the top left cell (the cell with coordinates (1,1)(1, 1) ). You need to move the chip to the bottom right cell (the cell with coordinates (n,n)(n, n) ).

In one step, you can move the chip to the neighboring cell, but:

  1. you can move only right or down. In other words, if the current cell is (x,y)(x, y) , you can move either to (x,y+1)(x, y + 1) or to (x+1,y)(x + 1, y) . There are two special cases:
  • if the chip is in the last column (cell (x,n)(x, n) ) and you're moving right, you'll teleport to the first column (to the cell (x,1)(x, 1) );
  • if the chip is in the last row (cell (n,y)(n, y) ) and you're moving down, you'll teleport to the first row (to the cell (1,y)(1, y) ).
  1. you cannot visit the same cell twice. The starting cell is counted visited from the beginning (so you cannot enter it again), and you can't leave the finishing cell once you visit it.

Your total score is counted as the sum of numbers in all cells you have visited. What is the maximum possible score you can achieve?

输入格式

The first line contains the single integer nn ( 2n2002 \le n \le 200 ) — the number of rows and columns in the grid.

Next nn lines contains the description of each row of the grid. The ii -th line contains nn integers ai,1,ai,2,,ai,na_{i, 1}, a_{i, 2}, \dots, a_{i, n} ( 0ai,j1090 \le a_{i, j} \le 10^9 ) where ai,ja_{i, j} is the number written in the cell (i,j)(i, j) .

输出格式

Print one integer — the maximum possible score you can achieve.

输入输出样例

  • 输入#1

    2
    1 2
    3 4

    输出#1

    8
  • 输入#2

    3
    10 10 10
    10 0 10
    10 10 10

    输出#2

    80
首页