树形dp(Fire)

电力远动入门:手把手解析IEC 60870-5-101规约的帧结构与报文交互(基于DL/T634.5101-2002) 本文深入解析IEC 60870-5-101规约的帧结构与报文交互,适用于电力远动通信系统。通过详细讲解规约的基础架构、控制域位定义及典型报文交互流程,帮助工程师快速掌握101规约的核心技术,提升电力自动化系统的调试与维护能力。 阅读详情

POJ 2152 经典树形dp
一张一弛,解题之道陈启峰
具体证明点上面的链接,最后一个例题就是题意也在里面;

题意:给定n个节点组成的树,树有边权.现在要在一些点上建立消防站,每个点建站都有个cost[i],如果不在当前的点上建站,也要依赖其他的消防站,并且距离不超过limit[i]。求符合上述条件的最小费用建站方案。n <= 1000.
best[i]代表以i为根的子树满足条件的最优解;
dp[i][j]代表 在i点选择j点为i点的负责点;
dis[i][j]代表i到j的距离;
当dis[i][j]<=limit[i]时还可以分成这么几个阶段:
(1):当j不是i的子树的时候,那么i的子节点x就有两种选择,一个是选择x的子树中的消防站,那么f[i][j]=best[x]。另 一种就是选择在x外的节点作为负责站,呢们根据上面个的那个性质我们可以知道i的负责站跟x的一样,那么f[i][j]=f[x][j]。
f[i][j]+=min(f[x][j],best[x]);
(2):选择i节点建消防站。
f[i][i]+=cost[i]+min(best[x],f[x][i]);
(3):选择i节点的子树为负责站,其实这种情况跟第一种很像
f[i][j]+=min(f[k][i]-cost[j],best[k])+cost[j];
这样以后我们就可以求解了。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
const int maxn=1e6+10;
const int inf=0x3f3f3f3f;
using namespace std;
int cost[maxn],limit[maxn],best[maxn],dp[1010][1010],cont,head[5010],dis[1010][1010],now,n;
struct zp
{
    int u,v,w,Next;
} node[maxn];
void init()
{
    memset(head,-1,sizeof(head));
    cont=0;
    memset(best,0x3f3f,sizeof(best));
    memset(dp,0x3f3f,sizeof(dp));
}
void add(int u,int v,int w)//建图
{
    node[cont].u=u,node[cont].v=v,node[cont].w=w;
    node[cont].Next=head[u];
    head[u]=cont++;
}
void getdis(int u,int fa,int len)//计算任意两点之间的距离
{
    dis[now][u]=len;
    for(int i=head[u]; i!=-1; i=node[i].Next)
    {
        int v=node[i].v;
        int w=node[i].w;
        if(v!=fa) getdis(v,u,len+w);
    }
}
void solve(int u,int fa)
{
    for(int i=head[u]; i!=-1; i=node[i].Next)//先递归,计算,从下往上
    {
        int v=node[i].v;
        if(v!=fa) solve(v,u);
    }
    for(int i=1; i<=n; i++)
    {
        if(dis[u][i]<=limit[u])//如果i点可以照顾到u点
        {
            dp[u][i]=cost[i];
            for(int j=head[u]; j!=-1; j=node[j].Next)//遍历u点的所有子节点
            {
                int v=node[j].v;
                if(v!=fa) dp[u][i]+=min(dp[v][i]-cost[i],best[v]);
            }
            best[u]=min(best[u],dp[u][i]);
        }
    }
}
int main()
{
    int ncase;
    scanf("%d",&ncase);
    while(ncase--)
    {
        init();
        scanf("%d",&n);
        for(int i=1; i<=n; i++)
            scanf("%d",&cost[i]);
        for(int i=1; i<=n; i++)
            scanf("%d",&limit[i]);
        for(int i=1; i<n; i++)
        {
            int a,b,c;
            scanf("%d%d%d",&a,&b,&c);
            add(a,b,c);
            add(b,a,c);
        }
        for(int i=1; i<=n; i++)
        {
            now=i;
            getdis(i,0,0);
        }
        solve(1,0);
        printf("%d\n",best[1]);
    }
}
识别产品外观的合格软件_工业视觉工业质检视觉识别机器视觉视觉检测智能制造工业检测缺陷... 随着工业物联网技术的迅猛发展,掀起了以云计算、大数据、以及人工智能 AI 等信息技术正与传统工业深入融合,由此衍生的 “智能制造4.0” 理念,正在为全球工业带来深远变革。中国的制造业巨头也纷纷借此发力,向智能化、数字化制造演进,实施战略转型。如何高效科学的管理和分析制造业务链上的生产价值,推进制造企业生产工艺优化与产品质量提升是每一个制造企业在数字化、智能化转型过程中的必经之路。业务发展带来的挑... 阅读详情

相关推荐

Windows 11最新WDK安装避坑指南:从Visual Studio配置到KMDF驱动开发

本文提供了在Windows 11系统上进行KMDF驱动开发的完整环境搭建与实战指南。针对最新WDK与Visual Studio的配置变化,详细解析了从独立安装WDK/SDK、创建首个KMDF驱动项目,到编译排错、部署调试的全流程,帮助开发者高效避坑,顺利开启Windows内核开发。

weixin_29302047的博客 525

Fire (poj 2152 树形dp)

Fire (poj 2152 树形dp) 给定一棵n个结点的树(1<n<=1000)。现在要选择某些点,使得整棵树都被覆盖到。当选择第i个点的时候,可以覆盖和它距离在d[i]之内的结点,同时花费为v[i]。问最小花费。 以前做过一道类似的题(水库),这道题也差不多。首先来考虑,用\(best[i]\)表示以i为根的子树的最小花费。这样做有什么问题呢?它无法很好的处理消防站...

171

别再混淆了!一张图看懂SAP特殊采购类30/40/70/80的区别与选型指南

本文深度解析SAP特殊采购类30/40/70/80的核心逻辑与业务影响,通过对比框架和真实案例帮助用户掌握其适用边界。重点介绍委外加工(类型30)、工厂间转移(类型40/70)及计划与执行分离(类型80)的配置要点与常见问题,提供选型决策树和实施检查清单,助力企业优化供应链管理。

weixin_26938645的博客 448

【POJ 2152】Fire【树形DP】

题意:给出一棵树,要求在节点出

Hacb的专栏 474

RTX 50系显卡实战3DGS:从源码编译到避坑指南

本文详细介绍了在RTX 50系显卡上成功运行3D Gaussian Splatting(3DGS)的完整实战指南。针对新显卡架构与旧版预编译包不兼容的核心问题,文章提供了从源码编译CUDA扩展的清晰步骤,包括环境配置、依赖安装、核心模块diff-gaussian-rasterization和simple-knn的编译避坑方法,并涵盖了数据准备、模型训练与实时预览的全流程,帮助开发者高效利用新硬件进行3D重建。

weixin_28314575的博客 261

实验五 循环结构第1关:斐波那契数列第2关:统计一段英文语句中的单词数和句子数第3关:密码判断第4关:通过数列求自然常数e第5关:双倍余额递减法计算固定资产折旧第6关:销售统计第7关:投资年限计算

第1关:斐波那契数列第2关:统计一段英文语句中的单词数和句子数第3关:密码判断 第4关:通过数列求自然常数e 第5关:双倍余额递减法计算固定资产折旧

pro_daily的博客 8168

Fire(依赖型树形dp)

https://cn.vjudge.net/problem/POJ-2152 Country Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and there is exact one path between two different cities. Recently cou...

永夜莫明的博客 323

AUTO-DL平台快速部署BEVFormer:Nuscenes数据集完整训练避坑指南

本文详细介绍了在AUTO-DL平台高效部署BEVFormer模型并利用Nuscenes数据集进行完整训练的实战指南。重点解析了平台数据管理、环境配置、数据集迁移解压、预处理及训练启动等全流程中的关键步骤与常见避坑技巧,帮助研究者和工程师快速复现这一前沿视觉感知模型,节省云端训练时间与成本。

weixin_29188043的博客 330

(树形dp)Fire

https://cn.vjudge.net/contest/264707#problem/D Country Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and there is exact one path between two different cities. Recen...

weixin_40588429的博客 240

STM32入门教程:WiFi通信

第四步:初始化串口 在生成的代码中,您可以找到一个名为 "USARTx_Init" 的函数,其中 "x" 是您选择的串口号。然后,我们使用 "AT+CIPSEND" 命令发送UDP数据,接收到服务器的回复,并在终端上显示收到的数据。在配置向导中,您可以选择启用USART串口功能,并根据您的硬件连接,将串口设置为与WiFi模块连接的串口。在上述代码中,我们使用了 "HAL_UART_Receive" 函数来接收串口数据,并使用 printf 来在终端上显示收到的数据。如果有任何问题,请随时向我提问。

2401_85258012的博客 1073

将指定文件夹下每张用LabelImg标注的图片中标注部分抠出来保存到指定文件夹下。

将指定文件夹下每张用LabelImg标注的图片中标注部分抠出来保存到指定文件夹下。

weixin_44119674的博客 437

poj 2152 Fire 树形dp

看题解,归纳一下做法吧: best[x]:表示以x为根的子树结点全部符合要求(在规定距离内有消防站)的最小花费。 dp[x][y]:表示x以y作为自己的消防站,且x的子树结点全部符合要求的最小花费。 那么处理每一个结点x时,先枚举和x距离不超过D[x]的点i,然后这些点可以作为x的消防站, 之后枚举x的子结点y,dp[x][i]=W[i]+sum(  dp[y][i]-W[i],b

便纵有千种风情 399

Imagiq AI-PQ 图像质量增强模块详解:联发科 ISP 中的 AI 图像管线实战解析

随着智能手机影像系统对图像质量要求的持续提升,联发科在其 Imagiq ISP 中引入了 AI 驱动的图像增强模块——AI-PQ(AI-based Picture Quality),通过 AI 模型对亮度、色彩、噪声、锐度等多个维度进行动态调节与增强,实现更加智能化和个性化的图像输出效果。AI-PQ 在实际工程中已成为影响照片风格、视频观感和多模组一致性的核心能力之一。本文围绕 Imagiq 平台最新一代 AI-PQ 模块(2024-2025年量产平台为基础),结合实机开发与调优经验,深入剖析其各子模块的算

努力分享一些人工智能、计算机视觉、影像等相关的知识干货! 1417

POJ 2152 Fire (树形dp)

转发一篇国家队论文。 树形dp 对这题讲的挺清楚的。 #include<iostream> #include<algorithm> #include<cstdio> #include<stdio.h> #include<string.h> #include<queue> #include<cmath> #inclu...

WayJasy的博客 242

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

POJ2152 Fire(树形 dp)

Description 给定一棵无根有权树,每个点建消防站都有一定代价 ccc,每个点都有一个限制 limlimlim,表示离它最近的消防站的最大距离。求让所有点安全的最小代价。 Solution 设 fi,jf_{i,j}fi,j​ 为以 iii 为根的子树全安全,且 jjj 管理 iii 的最小代价,bestibest_ibesti​ 为以 iii 为根的子树全安全的最小代价,结果显然为 be...

ylxmf2005's Blog 201

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

POJ 2152 Fire 很难的树形DP

题意:有N个城市,连接这些城市的道路组成了一个树形的结构。现在想在一些城市建立消防站。如果选择在城市i建立消防站,需要的费用是w i  w_i,这个消防站负责该城市的防火工作。如果不选择建立消防站,那在距离为d i  d_i的范围内要有一个消防站来负责城市i的防火工作。现在想让所有城市都能保证安全,求最小的费用。 思路:想了很长时间,以为和前面的独立集是相关的,但是怎么也想不出来。。就去搜题解了。

leodestiny 1286

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Poj 2152 Fire (DP_树形DP)

题目链接:http://poj.org/problem?id=2152 题目大意:给定n个节点组成的树,树有边权.现在要在一些点上建立消防站,每个点建站都有个cost[i],如果不在当前的点上建站,也要依赖其他的消防站,并且距离不超过limit[i]。求符合上述条件的最小费用建站方案。n 解题思路:复杂度为O(n^2)的树形DP.因为要依赖其他站点,所以不仅仅只从子树中获

3277

poj 2152 Fire (树形dp)

DescriptionCountry Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and there is exact one path between two different cities. Recently country Z often caught fire, so t

阿柟喜欢吃小星星? 373

[POJ2152] Fire [树形dp]

[Link\frak{Link}Link] 题意:在树里面选一些点建firehouse,满足所有的点在Di范围内都有firehouse。 求mincost。 这个题目很容易让人联想到某道消防局的设立 当然实际上差了很多( each vertice都要被control,朴素地想就是对于每一个点枚举一个firehouse 然后就搞出来一个n!做法当然是不行的啦。 所以得有更加确定的状态。尝试约...

最后一次修改 296

Fire - POJ 2152 树形dp

Fire Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 1098   Accepted: 546 Description Country Z has N cities, which are numbered from 1 to N. Cities are co

提比的强行AC 887

【poj2152】Fire 树形DP

DescriptionCountry Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and there is exact one path between two different cities. Recently country Z often caught fire, so t

DQS的树洞 1346

【POJ2152】Fire——树形DP

Fire 树形DP

Johann的博客 737

【poj2152】【Fire】【树形dp】

Fire Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 1161 Accepted: 595 DescriptionCountry Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and t

Vampire 1499

POJ 2152 Fire 树形dp 压行大法好

题意:在树上建消防站,给出树边的距离,给出每个点建消防站的花费和能覆盖的距离,要求建消防站覆盖整张图,问最小花费是多少。   这题贪心?没法做。暴力枚举搜索,just wash wash and sleep!   我们还是树形dp吧,其实n^2的树形dp我是之前没见过的,怎么搞?这里面蕴藏的东西还是很暴力的。。。   我们这样,先搞出dis[x][y]表示点x到点y的距离!暴力就好...

daxian3723的博客 200

poj2152 Fire(树形DP)

题目链接:https://vjudge.net/problem/POJ-2152 题意:给定一颗大小为n的树,在每个结点建消防站花费为w[i],如果某结点没有消防站,只要在它距离<=d[i]的结点有消防站即可,求最小花费。 思路:   好难的树形dp,一点思绪也木有,只能搜题解。   用dp[u][i]表示以u为根的子树满足条件,并且结点u依赖于结点i的最小花费。用best...

weixin_30757793的博客 180

POJ2152 Fire 树形DP

题目大意:n个城市组成一棵树,要在其中若干城市修建消防站。其中,在城市i修建消防站需要花费w[i]。最后想达到这样的状态,对于每个城市j,使得离其最近的消防站的距离不超过d[j]。问,达到这种状态的最小花费。 一读完,就觉得好难,仔细思考了一天,发现确实好难 = = 然后,...,然后就去看陈启峰的论文《一张一弛,解题之道》 状态设计为dp[i][j],表示对i为根的子树,满

ACMmaxx的专栏 843
上一篇: 树形dp
下一篇: 区间dp
acmer_zp
博客等级 码龄11年 18粉丝 110原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值