Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <bits/stdc++.h>using namespace std;const int N = 100;const int MAX = 2 * N * 100 + 2;int a[N + 5][N + 5], dp[N + 5][N + 5][2 * N + 5][2], cost[N + 5];int main() {cost[1] = 1;for (int i = 2; i <= N; ++i) {cost[i] = min(MAX, cost[i - 1] << 1);}int n;scanf("%d", &n);for (int i = 0; i <= n; ++i) {for (int j = 0; j <= n; ++j) {for (int k = 0; k <= 2 * n; ++k) {dp[i][j][k][0] = dp[i][j][k][1] = MAX;}}}for (int i = 1; i <= n; ++i) {for (int j = 1; j <= n; ++j) {scanf("%d", &a[i][j]);}}for (int i = 1; i <= n; ++i) {for (int j = 1; j <= n; ++j) {if (i == 1 && j == 1) {