Lang:G++
Edit12345678910111213141516171819202122232425262728293031// author : zt zou#include<bits/stdc++.h>using namespace std;#define MAX_VAL 1000005#define MAX_ARRAY_SIZE 200#define ms(x,v) memset((x),(v),sizeof(x))#define pb push_back#define fi first#define se second#define mp make_pair#define INF 0x3f3f3f3ftypedef long long LL;typedef pair<int,int> Pair;std::vector<int> G[MAX_ARRAY_SIZE];int n,root;int dp[MAX_ARRAY_SIZE][2];int op[MAX_ARRAY_SIZE];inline bool isleaf(int v){return G[v].empty();}inline Pair calc_and(int lc,int rc){int val1= dp[lc][1] + dp[rc][1];int val0 = min(dp[lc][0]+ min(dp[rc][1],dp[rc][0]), dp[rc][0] + min(dp[lc][1],dp[lc][0]));return mp(val0,val1);