(ssl1761)城市问题

【基础算法】铲雪车问题(BZOJ1190) 问题 L(1190): 【基础算法】铲雪车问题 时间限制: 1 Sec  内存限制: 64 MB 提交: 132  解决: 56 [提交][状态][我的提交] 题目描述 大雪覆盖了整座城市,市政府要求冬季服务部尽快将一些街道(列在一份清单中)的积雪清除掉以恢复交通。整个城市由许多交叉路口和街道构成,当然任意两个交叉路口都是直接或间接连通的。清单给出了最少的街道,使得这些街道的 阅读详情

城市问题

Time Limit:10000MS  Memory Limit:65536K
Total Submit:242 Accepted:89 
Case Time Limit:1000MS

Description

  设有n个城市,依次编号为0,1,2,……,n-1(n<=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于1000)。当两城市之间的距离等于-1时,表示这两个城市没有直接连接。求指定城市k到每一个城市i(0<=I,k<=n-1)的最短距离。 

Input

第一行有两个整数n和k,中间用空格隔开;以下是一个NxN的矩阵,表示城市间的距离,数据间用空格隔开。

Output

输出指定城市k到各城市间的距离(从第0座城市开始,中间用空格分开)

Sample Input

3 1
0 3 1
3 0 2
1 2 0

Sample Output

3 0 2

Source

elba

var
 a:array[0..1000,0..1000]of longint;
 l:array[0..1000]of longint;
 v:array[0..1000]of boolean;
 n,k,i,j,kk:longint;
 min:real;
begin
 readln(n,k);
 k:=k+1;//0到n-1个城市,所以要+1(理论上后面的循环用"0 to n-1"也可以,但是就是错了...)
 for i:=1 to n do
  begin
   for j:=1 to n do
    begin
     read(a[i,j]);
     if a[i,j]=-1 then a[i,j]:=maxlongint;
    end;
   readln;//换行
  end;
 fillchar(v,sizeof(v),true);
 v[k]:=false;
 for i:=1 to n do l[i]:=a[k,i];
 for i:=1 to n do
  begin
   min:=maxlongint;
   for j:=1 to n do
    if (v[j])and(l[j]<min) then
     begin
      kk:=j;
      min:=l[j];
     end;
   if kk<>0 then
    begin
     v[kk]:=false;
     for j:=1 to n do
      if (v[j])and(l[j]>a[kk,j]+l[kk])and(a[kk,j]<>maxlongint)then l[j]:=l[kk]+a[kk,j];//新条件判断是否连通
    end;
  end;
 for i:=1 to n do
  write(l[i],' ');//城市k到各城市间的距离
end.
//详见上一条博客,只改了输入和判断条件(一下水2题的快感~)http://blog.csdn.net/ssl_lzx/article/details/69261102

恶意流量检测数据集 对当前公开的恶意流量相关数据集进行归类总结,持续更新相关论文 阅读详情

相关推荐

Versal ACAP NoC实战:像理解计算机网络一样配置AXI NoC,打通PS与PL数据通路

本文深入探讨了Versal ACAP NoC的配置与优化,通过计算机网络类比解析NoC架构,详细介绍了在VD100开发板上配置AXI NoC实现PS与PL数据交互的实战步骤。文章涵盖NoC组件功能、Vivado配置技巧、性能优化方法及常见问题解决方案,帮助开发者高效打通Versal芯片的数据通路。

weixin_42665255的博客 297

ssl2334 铲雪车

Description 随着白天越来越短夜晚越来越长,我们不得不考虑铲雪问题了。整个城市所有的道路都是双车道,因为城市预算的削减,整个城市只有1辆铲雪车。铲雪车只能把它开过的地方(车道)的雪铲干净,无论哪儿有雪,铲雪车都得从停放的地方出发,游历整个城市的街道。现在的问题是:最少要花多少时间去铲掉所有道路上的雪呢? Input 输入数据的第1行表示铲雪车的停放坐标(x,y),x,y为

qq_34593871的博客 2803

工程制图习题集张大庆课后习题答案解析

所以,我想向大家求助,希望能得到一些学习资料、学习方法和学习经验,帮助我更好地理解和掌握这门课程。在寻找学习资料的过程中,我发现了一款叫做资小料的APP,它里面有很多关于工程制图的学习资料,包括视频教程、习题解答和考试真题等。通过使用资小料,我逐渐掌握了工程制图的基本理论和方法,解决了很多学习中遇到的问题。在这里,我想推荐给和我一样在学习《工程制图习题集》这门课的同学们,希望大家也能从这款APP中受益,共同进步。上传者: 『Consentesdei』蒼迷穀。出版社: 清华大学出版社。

weixin_58833001的博客 930

AcWing 1123 铲雪车

AcWing 1123 题目描述: 随着白天越来越短夜晚越来越长,我们不得不考虑铲雪问题了。 整个城市所有的道路都是双向车道,道路的两个方向均需要铲雪。因为城市预算的削减,整个城市只有 1 辆铲雪车。 铲雪车只能把它开过的地方(车道)的雪铲干净,无论哪儿有雪,铲雪车都得从停放的地方出发,游历整个城市的街道。 现在的问题是:最少要花多少时间去铲掉所有道路上的雪呢? 输入格式 输入数据的第 1 行表示...

linwenqidbk的博客 514

Linux内存压力测试工具【memtester】详且精

对Linux下的压力测试工具memtester有一个比较人性化的概述,以及避坑心得。

weixin_44118923的博客 1万+

【原创】汇川H5U PLC控制伺服的方法

6、在线调试-进入伺服调试,可以在本软件上进行调试,可以实现原点回归、正向点动、反向电动、使能(这里使能打开时触摸屏上的使能不能打开,会冲突)、复位、停止(如下图所示)。5、在原点返回设置中一般情况下对原点信号、正限位、负限位、原点返回方向、原点返回方式进行设置,其他设置默认不改(如下图所示)。3、在单位换算设置上只需要修改脉冲数和移动量(根据伺服配套导轨上名牌进行设置),其他设置默认不改(如下图所示)。11、双击后右边出现编辑框 在上半部分定义变量(IN、INOUT、OUT、VAR)(如下图所示)。

Qinmingyue13的博客 6691

cqyz oj | 【训练题】铲雪车问题

Description   大雪覆盖了整座城市,市政府要求“交通部门”尽快将一些街道(列在一份清单中)的积雪清除掉以恢复交通。整个城市由许多交叉路口和街道构成,当然任意两个交叉路口都是直接或间接连通的。清单给出了最少的街道,使得这些街道的积雪清除后任意两个交叉路口之间有且仅有一条通路。冬季交通部门只有一辆铲雪车和一名司机,这辆铲雪车的出发点位于某个交叉路口S。   无论街道上有没有积雪,...

banla3330的博客 509

基于STM32单片机设计的红外测温仪(带人脸检测)_34

当前设计的这款红外非接触式测温仪由测温硬件+上位机软件组合而成,主要用在地铁、车站入口等地方,可以准确识别人脸进行测温,如果有人温度超标会进行语音提示并且保存当前人脸照片。

8776

【SSL】1761城市问题

【SSL】1761城市问题 Time Limit:1000MS Memory Limit:65536K Description 设有n个城市,依次编号为0,1,2,……,n-1(n<=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于1000)。当两城市之间的距离等于-1时,表示这两个城市没有直接连接。求指定城市k到每一个城市i(0<=I,k<=n-1)的最短距离。 Input 第一行有两个整数n和k,中间用空格隔开;以下是一个NxN的矩阵,表示城市间的距离,数据

weixin_46975572的博客 260

上午题目复习ing

无线局域网,11b是常用的,2.4ghz,后来改进5ghz,有些字段可以工作在5g的字段802.11/11a/1h/11n,,,,,11b和11g还在2.4ghz工作。数据链路层 传输服务,数据链路维护,差错控制,arp ip到mac,rarp反过来,token ring,x.25,atm,ethernet,蓝牙10m,简化因特网,分散式网,快调频,短包,点对点,点多多点,2.4ghz,最高速率1mb/s。gsm:是时分多址,900m-1800m,微蜂窝是市区,微微风是室内,伞是盲点,

weixin_47120900的博客 895

智能车图像处理1-基础图像规格

从厂家摄像头的库函数中,我们可以直接得到完整图像的灰度数组,经过二值化之后(算力允许,可以考虑大津法),就是我们要处理的0-1二值图像了。本系列所有的文章中,我们的图像规格如下。

taiyuezyh的博客 4365

【SSL_P1761】城市问题

城市问题 题目描述:城市问题 题目描述 设有n个城市,依次编号为0,1,2,……,n-1(n<=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于1000)。当两城市之间的距离等于-1时,表示这两个城市没有直接连接。求指定城市k到每一个城市i(0<=I,k<=n-1)的最短距离。 输入格式 第一行有两个整数n和k,中间用空格隔开;以下是一个NxN的矩阵...

你...你不要过来啊!!! 263

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

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

城市问题【SSL 1761】

题目 Description   设有n个城市,依次编号为0,1,2,……,n-1(n Input 第一行有两个整数n和k,中间用空格隔开;以下是一个NxN的矩阵,表示城市间的距离,数据间用空格隔开。 Output 输出指定城市k到各城市间的距离(从第0座城市开始,中间用空格分开) Sample Input 3 1 0 3 1 3 0 2 1 2 0 Samp

Nowed 339

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

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

SSL P1761 城市问题

题目: http://blog.csdn.net/qq_35786326/article/details/79049278 题意: 求一个城市到其他城市的距离最小值 分析: 如果有些基础的童鞋,如果没有基础的可以去看我的算法大合集。其实这道题可以直接使用Dijkstra, 求出来后直接输出,那就美滋滋 代码: #include #include #include #include

qq_35786326的博客 238

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

【最短路】【SPFA】城市问题(ssl 1761)

城市问题 题目大意: 求一个点到其它点的最短路

ssllyf的博客 519

SSL_1761【城市问题】

城市问题 题目 设有n个城市,依次编号为0,1,2,……,n-1(n<=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于1000)。当两城市之间的距离等于-1时,表示这两个城市没有直接连接。求指定城市k到每一个城市i(0<=I,k<=n-1)的最短距离。 Input 第一行有两个整数n和k,中间用空格隔开;以下是一个NxN的矩阵,表示城市间的距离,数据间用空格隔开。 Output 输出指定城市k到各城市间的距离(从第0座城市开始,中间用空格分开) Sample

zhanglili1597895的博客 170

【SSL 1761】城市问题【最短路 Dijkstra】

Description 设有n个城市,依次编号为0,1,2,……,n-1(n<=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于1000)。当两城市之间的距离等于-1时,表示这两个城市没有直接连接。求指定城市k到每一个城市i(0<=I,k<=n-1)的最短距离。 Input 第一行有两个整数n和k,中间用空格隔开;以下是一个NxN的矩阵,表示城市间的距...

绫 470

【SSL1761】城市问题【floyed最短路】

Description 设有n个城市,依次编号为0,1,2,……,n-1(n<=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于1000)。当两城市之间的距离等于-1时,表示这两个城市没有直接连接。求指定城市k到每一个城市i(0<=I,k<=n-1)的最短距离。 Input 第一行有两个整数n和k,中间用空格隔开;以下是一个NxN的矩阵,表示城市间的距...

ssllyr 461

SSL-ZYC 1761 城市问题

题目大意: 给出n个城市两两之间的距离(距离为-1则为没有直接连接的路),求第m个城市到各个城市的最短距离。 注意:这里城市的编号从0开始,也就是说,如果有100个城市,则每个城市的编号为0、1···99! 思路: 千万注意题目中加粗的那行字!!! 也就是说,如果你用1···n来表示城市的编号,你最终输出的城市编号应该是m+1! 然后...

weixin_30904593的博客 145

城市问题-SSL 1761

Description   设有n个城市,依次编号为0,1,2,……,n-1(n<=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于1000)。当两城市之间的距离等于-1时,表示这两个城市没有直接连接。求指定城市k到每一个城市i(0<=I,k<=n-1)的最短距离。 Input 第一行有两个整数n和k,中间用空格隔开;以下是一个NxN的矩阵,表示城市间的距离,数据间用空

chenhongyi6的博客 322

(ssl 1761)城市问题#dijkstra#

Description   设有n个城市,依次编号为0,1,2,……,n-1(n&amp;lt;=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于1000)。当两城市之间的距离等于-1时,表示这两个城市没有直接连接。求指定城市k到每一个城市i(0&amp;lt;=I,k&amp;lt;=n-1)的最短距离。 因为从一个地方开始,so floyd就显得too slow 所以就用d...

lemondinosaur的博客 359

SSL P1761 城市问题 题目

城市问题 Time Limit:10000MS  Memory Limit:65536K Total Submit:326 Accepted:119 Case Time Limit:1000MS Description   设有n个城市,依次编号为0,1,2,……,n-1(n<=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于100

qq_35786326的博客 330

SSL 1761——城市问题[最短路]

Description   设有n个城市,依次编号为0,1,2,……,n-1(n<=100),另外有一个文件保存n个城市之间的距离(每座城市之间的距离都小于等于1000)。当两城市之间的距离等于-1时,表示这两个城市没有直接连接。求指定城市k到每一个城市i(0<=I,k<=n-1)的最短距离。 Input 第一行有两个整数n和k,中间用空格隔开;以下是一个NxN的矩阵,表示城市间的距离,数据

OIer 621
上一篇: (ssl1613)最短路径问题
下一篇: (ssl1760)商店选址问题
SSL_lzx
博客等级 码龄10年 19粉丝 202原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值