teacher_code_c/矩阵取数记忆.cpp

62 lines
1.7 KiB
C++
Raw Permalink Normal View History

//#include <iostream>
//#include <vector>
//#include <algorithm>
//
//using namespace std;
//
//int n, m;
//vector<vector<long long>> dp; // <20><><EFBFBD><EFBFBD><E4BBAF><EFBFBD><EFBFBD>
//
//// <20><><EFBFBD><EFBFBD> 2^power
//long long powerOfTwo(int power) {
// long long result = 1;
// for (int i = 0; i < power; ++i) {
// result *= 2;
// }
// return result;
//}
//
//// <20>ݹ麯<DDB9><E9BAAF><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>β<EFBFBD><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
//long long findMaxRecursive(const vector<int>& b, int left, int right, int power) {
// if (left > right) {
// return 0;
// }
// if (left == right) {
// return b[left] * powerOfTwo(power);
// }
// if (dp[left][right] != -1) { // <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7>ؽ<EFBFBD><D8BD><EFBFBD>
// return dp[left][right];
// }
// long long maxHead = findMaxRecursive(b, left + 1, right, power + 1) + b[left] * powerOfTwo(power);
// long long maxTail = findMaxRecursive(b, left, right - 1, power + 1) + b[right] * powerOfTwo(power);
// dp[left][right] = max(maxHead, maxTail); // <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// return dp[left][right];
//}
//
//long long solve(const vector<vector<int>>& matrix) {
// long long totalMaxScore = 0;
// for (const auto& row : matrix) {
// int rowSize = row.size();
// // <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD> dp <20>Ĵ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
// dp = vector<vector<long long>>(rowSize, vector<long long>(rowSize, -1));
// totalMaxScore += findMaxRecursive(row, 0, rowSize - 1, 1);
// }
// return totalMaxScore;
//}
//
//int main() {
// cin >> n >> m;
// vector<vector<int>> a(n, vector<int>(m));
//
// // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
// for (int i = 0; i < n; i++) {
// for (int j = 0; j < m; j++) {
// cin >> a[i][j];
// }
// }
//
// cout << solve(a) << endl;
//
// return 0;
//}