解题思路
dp[i][0]表示第i个节点不翻转的最优解,dp[i][1]表示翻转的最优解,每个位置翻转的代价到其父亲节点的位置再计算。
代码
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn =
dp[i][0]表示第i个节点不翻转的最优解,dp[i][1]表示翻转的最优解,每个位置翻转的代价到其父亲节点的位置再计算。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn =