多校联合训练10&&HDU 5861 Road

信息学奥赛选手必看:OpenJudge NOI 1.7 ‘过滤空格’题的三种解法深度对比与避坑指南 本文深入解析OpenJudge NOI 1.7 '过滤空格'题的三种解法,包括字符数组、string类和动态输入,对比其性能与适用场景,为信息学奥赛选手提供实用的避坑指南和优化建议。 阅读详情

【题意】

            给你n个村庄,每两个相邻的村庄有一条路,m个操作,每次都要从一个村庄走到另外一个村庄,每一条路每次都有一个维修的费用,每条路一开始是关闭的,你可以打开一次,关闭一次。问你最少的费用是多少。

【解题方法】

           copy一遍题解:为了使得花费最小,对于一段路来说,它的打开时间就是最早一次被用到到最后一次被用到这段时间.对于每一个操作a,b,在两个点上打上标记,从左至右做一遍扫描,可知道每段路当前有哪些操作会用到它,取出最大值和最小值,在这两个位置打上标记,最后对结果再进行一次扫描即可.

【AC 代码】

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
int w[maxn],c[maxn];
vector<int>v[maxn];
set<int>s;
int mx[maxn],mi[maxn];

int main()
{
    int n,m,l,r;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(int i=1; i<n; i++) scanf("%d",&w[i]);
        s.clear();
        for(int i=1; i<maxn; i++) v[i].clear();
        memset(c,0,sizeof(c));
        for(int i=1; i<=m; i++){
            scanf("%d%d",&l,&r);
            if(l>r) swap(l,r);
            v[l].push_back(i);
            v[r].push_back(-i);
        }
        for(int i=1; i<n; i++){
            for(auto j : v[i]){
                if(j>0) s.insert(j);
                else s.erase(-j);
            }
            if(s.size()){
                mx[i] = *s.rbegin();
                mi[i] = *s.begin();
            }
            else{
                mx[i] = m+1;
                mi[i] = m+1;
            }
        }
        for(int i=1; i<n; i++){
            c[mi[i]] += w[i];
            c[mx[i]+1] -= w[i];
        }
        int sum = 0;
        for(int i=1; i<=m; i++){
            sum += c[i];
            printf("%d\n",sum);
        }
    }
    return 0;
}


2012ACM多校联合比赛解析 ACM2012多校比赛解析,里面的分析十分详细,标程很不错! 立即下载

相关推荐

Java云上香云祭祀线上祭祀系统小程序源码

云上香云祭祀线上祭祀系统”,不仅是一种祭祀方式的创新,更是对传统文化的一次深情致敬。它让我们明白,无论时代如何变迁,对亲人的怀念与尊重永远不会改变。在这个特别的平台上,让我们共同守护那份跨越时空的爱与思念,让心灵得以安放,让生命之树常青。🌳。

2401_84413757的博客 806

HDU多校联合训练 Problem1001 Abandoned country

Problem Description An abandonedcountry has n(n≤100000) villageswhich are numbered from 1 to n. Since abandonedfor a long time, the roads need to be re-built. There are m(m≤1000000) roads to be r

lmz752981055的博客 357

YOLOv5模型转换陷阱:从PT到RKNN的置信度异常与乱框问题深度解析

本文深度解析了YOLOv5模型从PT到RKNN转换过程中的置信度异常与检测框错乱问题,揭示了NPU硬件特性与模型结构不匹配的根本原因。通过详细的解决方案和实操步骤,包括模型修改、转换流程配置和验证技巧,帮助开发者有效解决这一常见部署难题,提升模型在瑞芯微芯片上的推理性能。

weixin_29062255的博客 914

Werewolf 2018杭电多校第六场I

Werewolf Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 367    Accepted Submission(s): 58   Problem Description "The Werewolves" is a pop...

remarkableyan的博客 541

浙政钉H5应用上架实战:从环境配置到发布避坑指南

本文详细解析浙政钉H5应用上架全流程,从环境配置到发布避坑指南。重点介绍Vue 2.6 + Node 14.21.3的稳定开发环境搭建、项目结构规范及常见报错解决方案,帮助开发者高效完成浙政钉H5应用上架流程。

weixin_27943395的博客 296

从MCU到MPU:瑞萨RZN2L上手初体验,给Cortex-M工程师的Cortex-R52入门避坑指南

本文详细介绍了从MCU到MPU的过渡经验,特别是瑞萨RZN2L开发板的实战避坑指南。针对Cortex-M工程师转向Cortex-R52内核的挑战,文章深入解析了启动流程、内存管理、中断响应等九大本质差异,并提供了硬件设计陷阱和软件迁移的实用技巧,帮助开发者快速适应MPU开发环境。

weixin_29158413的博客 259

HDU 多校联合训练第六场 1009 ( Werewolf )

Werewolf Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 0 Accepted Submission(s): 0 Problem Description “The Werewolves” is a popular...

ACM2017 669

形式化方法(Formal Methods)和人工智能(Artificial Intelligence)

一、形式化方法(Formal Methods) ​ 形式化方法最初应用在硬件上,验证硬件的正确性,后面逐渐应用到软件编程中,能够在软件中找到软件的错误,验证软件的安全可靠。形式化方法更加接近离散数学,所以其应用难度非常大,同时学习成本也较高。再加上形式化方法的大多数理论还停留在上个世纪,由于程序越来越复杂,导致形式化方法进行验证需要大量人工和时间,以至于现在绝大部分软件开发人员完全没有考虑过这个方法,甚至没有听说过这个名词。 ​ 形式化方法最新的应用成果是在工业上,比如一些极其重要且对安全性要求极高的领域(

qq_37030400的博客 4018

多校集训记

Day 0  今天集训的人就要过来了~~ 蜜汁激动. 本来班上冷清的6个人终于又要热闹起来啦!! 早上随便改了一下昨晚考试的题目, 睡过了一个早上.   睡完觉来到机房发现一堆不认识的人在机房面前?? Doggu已经在热情的招待了hh. 好像是衡水的. 心中咯噔一下默默绕开回到自己机房前, 看着进来的这一群明天可能AK的神犇们. 随便写了一道哈夫曼树的题就下去打球了, 和wys跟两位衡水的同学打乒

Le Petit Prince 928

[网络安全提高篇] 一二〇.恶意软件动态分析经典沙箱Cape批量提取动态API特征

这是作者网络安全自学教程系列,主要是关于安全工具和实践操作的在线笔记,特分享出来与博友们学习,希望您喜欢,一起进步。前文详细介绍动态分析沙箱Cape的安装过程,其是一个开源的自动恶意软件分析系统,通过自动运行和分析恶意软件,全面分析和提取恶意软件的关键特征。然而,当样本数量增加时,单个样本分析会降低效率。这篇文章将讲解如何实现Cape沙箱的批量分析,通过调用Python脚本文件来实施批量处理,并将分析结果存储在指定位置,最后补充submit.py的参数及Python调用方式。基础性文章,希望对您有帮助!

杨秀璋的专栏 4128

【转录调控网络】代谢组学与其他组学的联合分析经典模式简介

多组学联合分析经典模式转录组学&代谢组学联合分析 转录组学&代谢组学联合分析 转录组是获得生物体内基因表达的重要方法,代谢组是生物体表型的基础和直接体现者。 转录组测序可以得到大量差异表达基因和调控代谢通路,但由于基因与表型之间很难之间关联,导致关键的信号通路难以确定,因此往往达不到预期的研究目的。代谢产物是生物体在内外调控下基因转录的最终结果,是生物体表型的物质基础。 在系统生物学研究时代,生物过程复杂多变,基因调控网络复杂。针对特定的生理、病理等表型进行研究,利用转录组的数据获得大量差异

小哲的博客 6204

多校联合集训(汇总)

结果 题目编号 标题 题解 正确 提交 Y 1001 字符串“水”题   93 265 Y 1002 小婷婷吃蘑菇   139 361 Y 1003 瑞神要考研

AI蜗牛之家 1198

uniapp [微信小程序] - 详解微信小程序端接入mqtt全流程及示例源码教程,uniApp微信小程序端如何接入MQTT插件并实现连接/断开+发布订阅+消息队列+离线重连等各种示例代码(开箱即用)

uniapp微信小程序接入MQTT,uniapp中使用mqtt,uniapp 微信小程序端接入mqtt示例代码教程,适用于微信小程序的MQTT插件,uniapp开发微信小程序连接mqtt,uniApp微信小程序接入MQTT协议,uniapp vue3微信小程序使用MQTT的小例子接入流程,使用uniapp开发小程序接入mqtt,如何在uniapp项目中使用mqtt,uniapp mqtt的使用示例,mqtt连接报错,如何在项目里集成mqtt,Mqtt协议,主动连接mqtt,订阅消息,实现发布,订阅和接收消息

🏆 前端领域优质创作者 2889

2018"ACM暑期多校联合训练"参(bao)赛(zha)记

(这毁了我一个暑假的东西) 时间 2018-7-23至2018-8-22,一星期2场,共10场,每场5个小时。 题目链接(楼教主:"是男人就过八(116)题") 评分规则 单场得分 = 本队本次解题数 / 本次比赛前200名队伍全部解题数 *(500-队伍排名)* 日期系数(30+x) 每次比赛只有前200名或者和第200名同样题数才有积分,否则0分 取全部10场比赛中成绩最好的8场...

墨染、青衣颜的博客 815

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

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

2018杭电多校第六场

                                           A - oval-and-rectangle   Patrick Star find an oval.  The half of longer axes is on the x-axis with length aa.  The half of shorter axes is on the y-axis wi...

Xuedan_blog的博客 839

怀旧版电脑GBC模拟器

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

HDU 6370 Werewolf 【基环内向树】(2018多校6)

Werewolf Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 957    Accepted Submission(s): 259 Problem Description "The Werewolves" is a popu...

LinzhiQQQ的博客 404

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

【2019 HDU多校集训第一场】

1.首先,总的来说HDU多校这次难度的是有的,但是并非表现得那么难,可能有很多队伍没有发挥好。 2.1005 Path.这个题目出了好多次了,基本套路,扣最短路跑最大流。 后记:有大佬说代码有些冗余,不用传dis数组,其实无所谓的,因为DJ哪个函数里已经每次把dis每次给重新赋值了。 #include<bits/stdc++.h> using namespace std; #d...

YG爱木木 924

2018 hdu多校联合训练一(1)

6298 Maximum Multiple 把整数因式分解,3的倍数一定可以,最小质因数5以上不可能(分数相加关系),只要考虑2、3、4。只是2的倍数而不是4的倍数,不会有三个因数相加为原数 #include&lt;bits/stdc++.h&gt; #define ll long long using namespace std; int main() { int n; ...

反之亦然 820

Werewolf( 推理+归纳)

Problem Description "The Werewolves" is a popular card game among young people.In the basic game, there are 2 different groups: the werewolves and the villagers. Each player will debate a player they...

海绵的博客 1340

Werewolf HDU - 6370 (找规律+并查集+bfs)

"The Werewolves" is a popular card game among young people.In the basic game, there are 2 different groups: the werewolves and the villagers.  Each player will debate a player they think is a werewolf...

untilyouydc 505

杭电多校 Werewolf(狼人杀,并查集+思维)

Werewolf Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 677    Accepted Submission(s): 159   Problem Description "The Werewolves" is a po...

Destinymiao的博客 944

2018多校第二场

  j题想复杂了,其实只要换就会减少逆序数,所以答案是,n*min(x,y);   G题,注意b为1~n的排列,所以,我们用一个数来记录当前的a值,当ai 等于 bi 时,我们更新该点,因为是1~N的排列,并且每次都是加一更新,所以复杂度没有想象中那么高,我们注意维护一下区间值,当发现ai==bi时更新单点就好了 补题的时候,把数组开小了,字符数组,还有mi数组忘了乘4 #includ...

DS00HY的小博客 302

杭电多校练习 Werewolf(狼人杀,并查集+思维)

Werewolf Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 677    Accepted Submission(s): 159   Problem Description "The Werewolves" is a po...

sher杨的博客 842

【HDU 6370】暑期多校day6 Werewolf (推理 基环树)

题目大意 有 n 个人在玩只有狼人和村民两种身份的狼人杀,他们在互相指认,形式为“ x 是狼人/村民”。限制:1)每个人都不能指认自己,2)村民必须说真话,3)狼人可能说谎。对于每组测试数据,要求输出一定为村民的玩家数目,一定为狼人的玩家数目。 http://acm.hdu.edu.cn/showproblem.php?pid=6370 解题思路 根据题意可知,村民只能说实话,而狼人既...

yashem66 479

2020杭电多校集训-Distinct Sub-palindromes

题目: S is a string of length n. S consists of lowercase English alphabets. Your task is to count the number of different S with the minimum number of distinct sub-palindromes. Sub-palindrome is a palindromic substring. Two sub-palindromes u and v are distin

world_started的博客 1868
上一篇: 2016多校联合训练10&&HDU5857 Median
下一篇: BZOJ 4668 冷战
just_sort
博客等级 码龄11年 2360粉丝 1667原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值