洛谷1967 货车运输(最大生成树)(LCA)

题解:洛谷 P1967 [NOIP 2013 提高组] 货车运输 等知名刷题平台精心挑选而来,并结合各平台提供的算法标签和难度等级进行了系统分类。题目涵盖了从基础到进阶的多种算法和数据结构,旨在为不同阶段的编程学习者提供一条清晰、平稳的学习提升路径。辆货车在运输货物,司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。行,每行一个整数,表示对于每一辆货车,它的最大载重是多少。每一条道路对车辆都有重量限制,简称限重。,之间用一个空格隔开,表示一辆货车需要从。,每两个整数之间用一个空格隔开,表示从。,两座城市之间可能有多条道路。#提高+# #生成树# 阅读详情

题目

A国有n 座城市,编号从 1 到 n,城市之间有 m 条双向道路。每一条道路对车辆都有重量限制,简称限重。现在有 q 辆货车在运输货物, 司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。

题解

最大生成树+lca求最小边权
有这么多条边,但每次都只会走那几条边权最大的边,其实,就是一棵最大生成树嘛。
把树找到后,设d[x][i]表示从x到f[x][i]中的最小边权,d[x][i]=min(d[x][i-1],d[f[x][i-1]][i-1])。
接下来的活儿交给lca。

总结

想要优化一个算法,不一定要用回这个算法。

代码

#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=10010,maxm=50010,maxq=30010;

int n,m;
struct E{int x,y,c,next;}a[maxm],e[maxn*2];int len=1,last[maxn];
bool cmp(E e1,E e2){return e1.c>e2.c;}//debug 最大生成树 
void ins(int x,int y,int c)
{
    e[++len]=(E){x,y,c,last[x]};last[x]=len;
}

int fa[maxn];
int findfa(int x)
{
    if(fa[x]==x) return x;
    return fa[x]=findfa(fa[x]);
}
void kruskal()
{
    for(int i=1;i<=n;i++) fa[i]=i;
    sort(a+1,a+m+1,cmp);
    for(int i=1;i<=m;i++)//debug 遍历所有边(不一定满n-1条) 
    {
        int fx=findfa(a[i].x),fy=findfa(a[i].y);
        if(fx!=fy)
        {
            ins(a[i].x,a[i].y,a[i].c);
            ins(a[i].y,a[i].x,a[i].c);
            fa[fx]=fy;
        }
    }
}

int head,tail,q[maxn];
int dep[maxn],f[maxn][20],d[maxn][20];
void bfs(int S)
{
    head=0,tail=1;q[0]=S;
    dep[S]=1;
    for(int i=0;i<=16;i++) d[S][i]=inf;
    while(head<tail)
    {
        int x=q[head++];
        for(int k=last[x];k;k=e[k].next)
        {
            int y=e[k].y;
            if(dep[y]) continue;
            dep[y]=dep[x]+1;
            f[y][0]=x;d[y][0]=e[k].c;
            for(int i=1;i<=16;i++)
            {
                f[y][i]=f[f[y][i-1]][i-1];
                d[y][i]=min(d[y][i-1],d[f[y][i-1]][i-1]);
            }
            q[tail++]=y;
        }
    }
}
int lca(int x,int y)
{
    int re=inf;
    if(dep[x]<dep[y]) swap(x,y);
    for(int i=16;i>=0;i--)
        if(dep[f[x][i]]>=dep[y])
        {
            re=min(re,d[x][i]);
            x=f[x][i];
        }
    if(x==y) return re;
    for(int i=16;i>=0;i--)
        if(f[x][i]!=f[y][i])
        {
            re=min(re,min(d[x][i],d[y][i]));
            x=f[x][i],y=f[y][i];
        }
    if(f[x][0]==f[y][0]) return min(re,min(d[x][0],d[y][0]));//debug 别忘了与f[x/y][0]之间的边 
    return inf;//x和y没有公共祖先 
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].c);
    
    kruskal();
    for(int i=1;i<=n;i++)//因为不连通,所以每个点都要检查 
        if(!dep[i]) bfs(i);
    
    int Q;scanf("%d",&Q);
    while(Q--)
    {
        int x,y,ans;
        scanf("%d%d",&x,&y);
        if(findfa(x)!=findfa(y)){puts("-1");continue;}//用并查集判是否连通
        ans=lca(x,y);
        printf("%d\n",ans==inf?-1:ans);
    }
    return 0;
}

 

信号检测算法的MATLAB仿真:能量检测、循环平稳检测和匹配滤波检测 根据具体的应用场景和要求,选择合适的信号检测算法可以提高系统的性能和可靠性。在无线电通信中,信号检测是一项重要的任务,它用于检测和识别接收到的信号。在本文中,我们将介绍三种常用的信号检测算法:能量检测、循环平稳检测和匹配滤波检测,并提供相应的MATLAB源代码进行仿真实现。在上述代码中,我们首先设置了能量检测的阈值,然后生成了一个包含1000个服从正态分布的随机信号样本的信号。在上述代码中,我们首先设置了信号模板,然后生成了一个包含信号模板的信号样本。最后,通过比较相关性的最大值与阈值来判断信号是否存在。 阅读详情

相关推荐

docker安装的 n8n提示Your n8n server is configured to use a secure cookie, however you are either visiting

将原来的docker n8n进行删除后即可通过一下方式重新安装,如安装完n8n,提示。

满地找牙的博客 3366

题解:NOIP2013-货车运输

老习惯,先上题目 题目描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路。每一条道路对车辆都有重量限制,简称限重。现在有 q 辆货车在运输货物, 司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。 输入输出格式 输入格式: 输入文件名为 truck.in。 输入文件第一行有两个用一个空格隔开的整数 n,m,表示 A 国有 n 座

Zctoylm的博客 613

用Python+NumPy手把手实现分数阶傅里叶变换(FRFT),搞定线性调频信号分析

本文详细介绍了如何使用Python和NumPy实现分数阶傅里叶变换(FRFT),特别针对线性调频信号(Chirp信号)分析。通过从零开始的代码实现和可视化案例,展示了FRFT在时变信号处理中的强大能力,帮助工程师和研究人员高效分析频率随时间变化的信号。

weixin_29062823的博客 218

洛谷P1967 [NOIP 2013 提高组] 货车运输

题目摘要 洛谷P1967 [NOIP2013提高组]货车运输:给定n个城市和m条双向限重道路,q次询问两城市间的最大载货量(即路径最小限重的最大值)。若无法到达则输出-1。 解题思路 最大生成树:构建最大生成树确保两点间路径的限重最大 树链剖分:将树结构转化为线性结构,便于查询 线段树:维护区间最小值,快速查询路径最小限重 关键算法 Kruskal算法构建最大生成树 树链剖分实现路径分解 线段树维护区间最小值查询 代码实现 使用结构体存储边,并查集实现Kruskal算法。通过两次DFS完成树链剖分,线段树处

yjfyjfyjf54188的博客 1099

告别混乱!AutoSar BswM模式管理实战:手把手教你配置Rule与ActionList(附避坑指南)

本文详细解析了AutoSar BswM模式管理的实战配置,重点介绍了Rule与ActionList的高效组合方法,帮助开发者避免常见陷阱。通过具体案例演示了从基础到复杂的配置步骤,包括模式仲裁、逻辑表达式构建及ActionList优化策略,提升汽车电子系统的协调性与可靠性。

weixin_27066963的博客 259

RK3588 C-PHY摄像头驱动升级踩坑记:从‘Only CSI2 supported’报错到成功取流

本文详细记录了在RK3588平台上调试C-PHY摄像头驱动的全过程,从‘Only CSI2 supported’报错分析到成功取流。内容涵盖C-PHY与CSI-2协议差异、SDK版本对比、V4L2框架下的bus-type解析机制,以及硬件排查与寄存器调优实战经验,为嵌入式Camera驱动工程师提供宝贵参考。

weixin_42522374的博客 123

【题解】NOIP-2013 货车运输

题目描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路。每一条道路对车辆都有重量限制,简称限重。现在有 q 辆货车在运输货物, 司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。 输入输出格式 输入格式: 输入文件名为 truck.in。 输入文件第一行有两个用一个空格隔开的整数 n,m,表示 A 国有 n 座城市和 m 条道 路。 接下来 m 行

测试运算符 1191

sentaurus学习笔记(HFET_pGate_GaN仿真)(五)

`(sdedr:define-constant-profile`和`(sdedr:define-constant-profile-region`命令用于定义并应用一个恒定的活性硼掺杂浓度剖面`"ndop_GaN_gate_const"`到氮化镓栅极层上,其值为`NpGaN_gate`。- `"Oxide"`指定了这一层的材料名称(在这里代表氧化层),而`"nucleation"`是这一层在仿真中的标识名称。- `"GaN"`指定了这一层的材料名称,而`"GaN_gate"`是这一层在仿真中的标识名称。

qq_52640792的博客 940

货车运输

题目描述 Description A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路。每一条道路对车辆都有重量限制,简称限重。现在有 q 辆货车在运输货物, 司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。  输入输出格式 Input/output 输入格式: 输入文件名为 truck.in。 输入文件第一行有两个用一个空

CRZbulabula的博客 606

[SVA]SystemVerilog Assertion Property开发技巧总结

SystemVerilog Assertion开发技巧总结 一、在property中可以使用if-else条件语句 如下面的例子,根据misc_phy_12g_rx的取值,选择不同的判断语句 property ck1_en_rose_chk(); @(posedge clk) disable iff(~rst_n) ad_pn_ck1en & (current_state !== ST_IDLE) |->...

元直的博客 5924

端侧 AI 落地避坑指南(中):为什么 QAT 救不了精度?——对齐“融合后算子“的硬件物理约束

在上一篇文章中,我们深入探讨了量化的本质,并得出结论:QAT(量化感知训练)是保持精度的关键。明明做了 QAT,精度还是崩塌了!让我们看一个真实的案例:✅ 使用了✅ 配置了量化✅ 训练了 50 个 epoch,学习率降为原来的 1/10✅ 冻结了 BN 统计量FP32 模型:mAP = 0.85QAT 后 FP32:mAP = 0.84(正常)工具量化后:mAP = 0.68(崩塌!问题出在哪里?层融合(Layer Fusion)机制。

weixin_51988935的博客 55

洛谷:P1967 [NOIP2013 提高组] 货车运输(LCA —— 求两点间路径上最小边的权值)

洛谷:货车运输 理解了求严格次小生成树那道题的做法,此题就很简单了,不过需要动脑筋贪心思维一下 #include<bits/stdc++.h> #include<unordered_set> #include<unordered_map> #define mem(a,b) memset(a,b,sizeof a) #define cinios (ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)) #define sca

酒姬民的博客 352

管好 SAP Fiori Launchpad Content:技术目录、业务目录与 KPI 工具的完整治理思路

SAP Fiori Launchpad 作为企业级统一入口,需通过技术目录(源对象)和业务目录(引用编排)分层治理。技术目录由 Launchpad App Manager 维护,负责应用描述对象(Tile 和 Target Mapping)的创建与管理;业务目录由 Launchpad Content Manager 编排,通过引用技术目录对象实现灵活配置。分析型内容则通过 F2814 统一管理。这种分层设计支持应用复用,便于升级维护,是 SAP S/4HANA 项目中实现高效内容治理的关键。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 130

(MST、lca)洛谷 P1967 NOIP2003 货车运输

考虑转化题意,运输的最大重量就是,司机经过的边的限重值的最小值。(这很有二分特征,可以整体二分做,不过现在不用这个做法)首先肯定要维护做 lca 的倍增数组了,类似地,我们维护一个倍增形式的最小值数组,记。辆货车在运输货物,司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。我们对这个无向图跑出一棵最大生成树,司机在树边上跑,肯定比跑其它的边更优呢!级祖先路上的边权最小值。,分别是对边排序和查询时在线求 lca,这个经典的做法常数很小,看。每一条道路对车辆都有重量限制,简称限重。

m0_60506105的博客 830

深度学习工具包 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")

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

洛谷P1967 货车运输 生成树+LCA 倍增

题目链接:https://www.luogu.com.cn/problem/P1967 这题我们可以知道有些边是肯定不会用到的,所以我们想办法去边。把这个图的最大生成树求出来即可。然后求两点的最小限重,用树上倍增求LCA,过程种更新最小限重。 代码如下 #include <bits/stdc++.h> using namespace std; const int maxn=1e4+5;...

hhhcbw的博客,欢迎各位来访 240

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

【题解】【洛谷 P1967】 货车运输

目录 洛谷 P1967 货车运输 原题 题解 思路 代码 洛谷 P1967 货车运输 原题 题面请查看洛谷 P1967 货车运输。 题解 思路 根据题面,假设我们有一个普通的图: 作图工具:Graph Edit...

weixin_30387663的博客 239

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

洛谷P1967 货车运输

最大生成树+LCA

a free man 499

【洛谷】P1967

图论 #重构树 #倍增。

Antonio915的博客 1254

LCA+最大生成树 货车运输(洛谷 P1967)

货车运输 题目描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路。每一条道路对车辆都有重量限制,简称限重。 现在有 q 辆货车在运输货物, 司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。 输入格式 第一行有两个用一个空格隔开的整数 n,m,表示 A 国有 n 座城市和 m 条道路。 接下来 m 行每行三个整数 x,y,z,每两个整数之间用一个空格隔开,表示...

不知所云的博客 291

洛谷-P1967货车运输

题解 洛谷P1967货车运输 说到1967,这是一个神奇的日子… 在公元1967年,在圆谷株式会社诞生了一个神作----ultra seven!!! 对于seven的知名度,L_Y_T略略的计算了一下: ans=(∑i=1nn−初代年份n∗1n)×100ans = (\sum_{i=1}^{n}\frac{n-初代年份}{n}*\dfrac{1}{n})\times100ans=(∑i=1n​nn...

L_Y_T020321的博客 342

洛谷1967 货车运输

to神犇:请自动跳过前x行的吐槽,因为吐槽内容可能只是一些极其无聊的bug和友情提示…… 一道极其经典且相当BT的图论题,不过目前看来与运输计划相比似乎更仁慈一些。在你下定决心AC这道题之前,你首先要做好debug到怀疑人生的准备,最好准备一瓶眼药水以备不测,当然有一份画风清奇简约养眼的题解也是极好的……;其次,你要明白这道题的代码长度——不压缩180左右——所以要有足够的耐心,找一把舒适的椅子

zero_from的博客 618

[洛谷 P1967] 货车运输 (最大生成树 lca)

[洛谷 P1967] 货车运输 (最大生成树 lca) 题目描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路。每一条道路对车辆都有重量限制,简称限重。现在有 q 辆货车在运输货物, 司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。 输入输出格式 输入格式: 输入文件...

Tricksterism 215

【题解】洛谷P1967 [NOIP2013TG] 货车运输(LCA+kruscal重构树)

洛谷P1967:https://www.luogu.org/problemnew/show/P1967 思路 感觉2013年D1T3并不是非常难 但是蒟蒻还是WA了一次 从题目描述中看出每个点之间有许多条路径 而我们需要的是找出整条路径中最大的最小可通过量 一开始看到题目会想到是不是最大流问题 但是仔细一想其实并不用那么麻烦 我们只需要用kruscal找出最大生成树...

206

洛谷P1967货车运输 最大生成树跑LCA

点我打开题目 题目描述: n个点,m条边,边为双向边,每条边有最大载重,q个询问,每个询问包含两个整数a和b,询问一辆货车从a到b可以的最大载重。 不保证一定有道路从a到b(保证a!=b)。 这个题目只要求最大载重,没有要求路径的距离,所以我们“贪心”的想,货车一定是走极限载重大的路,所以我们需要删掉一部分边,这些边是一定不会走的,但是删边的同时,必须要保证原本互相连通的两个点不会因此而不连通,还...

bestjerry007的博客 253

P1967 货车运输(倍增LCA,生成树)

题目链接: https://www.luogu.org/problemnew/show/P1967 题目描述 A国有n座城市,编号从1到n,城市之间有m条双向道路。每一条道路对车辆都有重量限制,简称限重。现在有q辆货车在运输货物, 司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。 输入输出格式 输入格式: 第一行有两个用一个空格隔开的整数n,m...

weixin_30699831的博客 94

洛谷 P1967 货车运输 (最大生成树+lca)

Link https://www.luogu.org/problemnew/show/P1967 Description  AAA国有nnn座城市,编号从 111到nnn,城市之间有mmm条双向道路。每一条道路对车辆都有重量限制,简称限重。现在有qqq辆货车在运输货物, 司机们想知道每辆车在不超过车辆限重的情况下,最多能运多重的货物。 Solution  一眼看去似乎是个最大流的问题,然而有很多查...

梧桐 382
上一篇: 洛谷2187 小Z的笔记(DP)
下一篇: bzoj 3249 [ioi2013]game(线段树)(伸展树)
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值