这题…就是很毒瘤。玄学map。玄学pair。否则大点炸掉。
解
-
DP。
ans[i]为第i颗树的美观度。
topx(nowt,x)为在第nowt颗树上所有点到x点的距离和
disx(nowt,x,y)为在第nowt颗树上x点到y点的距离 -
关于转移:
(模拟一下,分类讨论一下,得到代码)
把当前的树拆成两个树(当初拼成它的数)然后判断各种情况,递归,记忆化搜索。虽然代码繁琐(chou)了(亿)点,但还是比较好理解的(?)
详见代码。(万能句) -
然后便是%%%%%%
(只要我%得够标准WA就找不上我)(再%亿%同机房的增加下RP)
%%%tjh(dalao
%%%lth(让我扣完了标
%%%fy(?美女快教我
为什么你们的题解都写那么长。呆滞。
代码
#include <cstdio>
#include <utility>
#include <cmath>
#include <map>
#include <iostream>
#include <cstring>
#define LL long long
#define N 101
#define mod 1000000007
using namespace std;
map <pair <LL, LL>, LL> dis[N];
map <LL, LL> top[N];
LL T, m, a[N], b[N], c[N], d[N], l[N], ans[N], size[N];
LL disx(LL nowt, LL x, LL y) //同颗树,x点走向y点
{
if(x == y) return 0;
if(x > y) swap(x,y);
pair<int, int> p = make_pair (x, y);
if(dis[nowt