地铁 CSU - 1808 dijkstra 拆点

深度学习中 Internal Covariate Shift 问题以及 Batch Normalization 的作用 深度学习中 Internal Covariate Shift 问题以及 Batch Normalization 的作用前言一、Batch Normalization是什么?1.1 Internal Covariate Shift1.2 Internal Covariate Shift 带来的影响1.3 如何减缓 Internal Covariate Shift 问题带来的影响白化(Whitening)白化存在的问题二、Batch Normalization2.1 传统 Normalization2.2 改进 阅读详情

题解

每个点有多个线路,不同线路之间切换需要额外代价,直接在队列的节点中记录当前线路编号增加额外代价无法得到最优解。
将原有节点拆分,使用map进行标号,如果当前节点有x个线路相连则将当前节点拆分为x个点,原边只在相同线路的点副本之间连接。
**每个节点,相邻站点编号的副本节点进行相连,代价为编号差。**不用每个副本都两两之间建立边,会导致极端复杂度M^2。
起始节点和终点的副本之间建立0代价边。表示从任意编号起点出发,到任意编号终点结束。最后dijkstra~。

AC代码

#include <stdio.h>
#include <bits/stdc++.h>
#define fst first
#define sed second
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10;
int n, m;
map<pair<int, int>, int> mp;
int idx;
bool vis[N];
ll dis[N];

struct node
{
	int v;
	ll w;
	bool operator < (const node &o) const
	{
		return w > o.w;
	}
};
vector<node> e[N * 3];
vector<int> t[N]; //每个节点车站数量

int code(int v, int c) //给节点编号
{
	int &res = mp[{v, c}];
	if (!res)
		res = ++idx;
	return res;
}
ll dijkstra()
{
	memset(vis, 0, sizeof(vis));
	memset(dis, 0x3f, sizeof(dis));
	int st = code(1, t[1][0]), ed = code(n, t[n][0]); //起点终点任意车站编号
	priority_queue<node> pq;
	pq.push({ st, 0 });
	dis[st] = 0;
	while (!pq.empty())
	{
		int u = pq.top().v;
		if (u == ed)
			return pq.top().w;
		pq.pop();
		vis[u] = 1;
		for (auto it : e[u])
		{
			int v = it.v;
			ll w = it.w;
			if (!vis[v] && dis[u] + w < dis[v])
				dis[v] = dis[u] + w, pq.push({ v, dis[v] });
		}
	}
	return -1;
}
int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	while (cin >> n >> m)
	{
		mp.clear();
		idx = 0;
		for (int i = 0; i < m; ++i)
		{
			int u, v, c, w;
			scanf("%d%d%d%d", &u, &v, &c, &w);
			t[u].push_back(c); //记录车站
			t[v].push_back(c);
			u = code(u, c), v = code(v, c); //编码
			e[u].push_back({ v, w });
			e[v].push_back({ u, w });
		}
		for (int i = 1; i <= n; ++i)
		{
			vector<int> &v = t[i];
			sort(v.begin(), v.end());
			v.erase(unique(v.begin(), v.end()), v.end());
			for (int j = 1; j < v.size(); ++j) //两个相邻编号建立额外边
			{
				int c1 = code(i, v[j - 1]), c2 = code(i, v[j]), w = v[j] - v[j - 1];
				if (i == 1 || i == n)
					w = 0; //起点终点的额外边权为0
				e[c1].push_back({ c2, w });
				e[c2].push_back({ c1, w });
			}
		}
		ll res = dijkstra();
		cout << res << endl;
		for (int i = 1; i <= idx; ++i) e[i].clear();
		for (int i = 1; i <= n; ++i) t[i].clear();
	}

	return 0;
}
51单片机 驱动有源/无源蜂鸣器+Proteus仿真 51单片机 驱动有源/无源蜂鸣器+Proteus仿真 相关篇《51单片机 Proteus仿真有源蜂鸣器始终不响原因及解决方法》 电路搭建 采用NPN管驱动有源蜂鸣器电路 采用PNP管驱动有源蜂鸣器电路 采用PNP管驱动无源蜂鸣器 采用NPN管驱动无源蜂鸣器 Proteus元器件列表 实例代码 /************************************************************************************* * 实验现象:下载程序 阅读详情

相关推荐

全志V3S开发板实战:从零构建嵌入式Linux系统

本文提供了一份针对全志V3S开发板(如LicheePi Zero)的零基础教程,详细指导如何从零开始构建嵌入式Linux系统。内容涵盖编译环境搭建、交叉工具链配置、U-Boot引导程序编译与烧录、Linux内核定制与编译,以及使用Buildroot构建根文件系统,最终实现系统成功启动,帮助开发者深入理解嵌入式系统构建全流程。

tensor9flow的博客 580

csu 1808 地铁 迪杰斯特拉+拆点建图

csu 1808 思路:2016年省赛的最短路题,去年省赛也是考了最短路,那么问题来了,今年会不会继续考最短路呢....这个题和一般的最短路不太一样,每个点还多了个路线,同一个点不同路线还得多花时间 |ci - cj | ,那么将点和路线结合(u,ci)看成一个点,前面输入的边容易转化成符合条件的边,但是问题来了,假设一个点u有1e5条路线,那么就有1e5个这样的点,如何在他们之间建立边呢,全部...

ccsu_cat 514

『与善仁』Appium基础 — 19、元素定位工具之UI Automator Viewer

文章目录(一)uiautomatorviewer定位工具1、uiautomatorviewer介绍2、uiautomatorviewer工具打开方式3、uiautomatorviewer布局介绍4、uiautomatorviewer工具的使用 之前我们在做web页面自动化的时候就说过,元素定位是页面自动化的第一步。 同理App自动化测试的第一步,也是元素的定位。 在APP中定位元素的话,需要借助一些元素定位工具。 APP中的元素定位工具大致有三种: uiautomatorviewer Appium Ins

繁华似锦Fighting 1523

Deliver the Cake (拆点 dijkstra)

传送门 这道题主要是建边麻烦,而稍微省点麻烦的就是拆点进行建边了,将所有 MMM 的点拆成左跟右,按部就班按照题目意思进行建边 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; template <typename T> inline void read(T &x) { int tmp = 1;char c = getc

bloom_er的博客 286

Nvidia Jetson AGX Orin 如何进入 Recovery Mode(刷机注意事项)

Jetson Orin 如何进入Recovery mode + 刷机注意事项

Pandako's Blog 1万+

高效静音黑科技 —— 单相直流无刷电机驱动器

然而,传统的BLDC电机驱动通常依赖于三相架构,电路复杂,成本高昂,且在低功率应用中显得有些“大材小用”。单相直流无刷电机驱动器作为一项高效、静音、经济的技术,正逐渐改变着各个领域的电机驱动方式。其精巧的控制策略、显著的优势以及广阔的应用前景,都预示着这项技术将在未来扮演越来越重要的角色。它相较于传统的三相驱动,显著简化了电路结构,降低了成本,尤其适用于低功率、对静音要求极高的应用场景。通过这些模块的协同工作,单相直流无刷电机驱动器能够实现对电机速度、扭矩的精确控制,并最大程度地降低噪声和振动。

wen8789的博客 1779

AcWing 383. 观光 ( dijkstra拆点求最短路数)

整理的算法模板:ACM算法模板总结(分类详细版) “您的个人假期”旅行社组织了一次比荷卢经济联盟的巴士之旅。 比荷卢经济联盟有很多公交线路。 每天公共汽车都会从一座城市开往另一座城市。 沿途汽车可能会在一些城市(零或更多)停靠。 旅行社计划旅途从 S 城市出发,到 F 城市结束。 由于不同旅客的景点偏好不同,所以为了迎合更多旅客,旅行社将为客户提供多种不同线路。 游客可以选择的...

wait 515

帆软报表JS导出避坑指南:如何正确处理sessionid和参数传递

本文深入探讨了帆软报表中通过JavaScript实现一键导出的关键技术,重点解析了如何正确获取并传递sessionid以确保会话不丢失,以及如何构造包含必要参数的导出URL。文章详细对比了预览后导出与直接URL导出两种方式的差异,并提供了从参数拼接、前端触发下载到高级场景(如SPA集成)的完整避坑指南,帮助开发者构建稳定可靠的自定义导出功能。

weixin_42522857的博客 167

hdu - 4725 最短路+拆点建图 dijkstra或spfa

题意:每个点放在一层,然后给了n个点,n层楼(一楼可多点),相邻的两层距离是固定的k,有额外m条边,然后求1到n的最短路径,如果没有则输出-1 重要的还是建图吧。每一层拆出来一个出点一个入点,从n+1~2n,从2n+1~3n,相邻层出连入权值为k;点在哪一层就:入~点~出。1~n就表示1~n这些点。时间卡的很恶心啊,spfa  998ms卡过一个其他的都是一样的代码都没过。。。。。。看网上用什么双...

陌离将离 406

基于YOLOv10的机器人抓取引导系统:从物体检测到精准抓取

python# 数据标注工具简化版import os"""启动标注工具""""""标注单张图像"""print(f"标注图像: {os.path.basename(img_path)}")print("请在图像上绘制抓取矩形框...")# 这里应该实现交互式标注界面# 简化版本直接返回示例标注# 示例标注数据"""保存标注结果"""# 保存为YOLO格式# 转换为YOLO格式。

YOLO 381

Python 爬虫实战:爬取股票数据做 K 线图可视化

摘要:本文介绍基于Python的股票数据爬取与K线图可视化全流程技术方案。通过Requests库抓取东方财富网股票数据,使用Pandas进行清洗处理,并利用mplfinance库实现专业K线图绘制。文章详细讲解了数据爬取接口分析、反爬策略配置、K线图绘制方法(包含基础K线图和带均线的进阶版本),以及核心统计指标计算。该方案可应用于股票价格趋势分析,为投资决策提供数据支持,同时强调了数据使用的合规性和技术优化方向。

2503_91057718的博客 2054

UVALive4128[Steam Roller] dijkstra+拆点

UVALive4128 dijkstra 拆点

Venishel的博客 460

基于STM32L4XX 、HAL库的DRV8912QPWPRQ1步进电机驱动器驱动程序应用设计

define DRV8912_REG_PWM0 0x14 /* PWM发生器0占空比寄存器 */#define DRV8912_CMD_WRITE (0x00 << 15) /* 写操作 (RW = 0) */#define DRV8912_CMD_READ (0x01 << 15) /* 读操作 (RW = 1) */#define DRV8912_REG_OCP 0x0C /* 过流保护配置 *//* 读操作时,数据字段通常写0 */

PP_Cottage的博客 63

[CSU 1808: 地铁] Dijkstra

[CSU 1808: 地铁] Dijkstra题目链接:[CSU 1808: 地铁] 题意描述:ICPCCamp 有 nn 个地铁站,用 1,2,…,n1,2,\ldots,n 编号。 mm 段双向的地铁线路连接 nn 个地铁站,其中第 ii 段地铁属于 cic_i 号线,位于站 ai,bia_i,b_i 之间,往返均需要花费 tit_i 分钟(即从 aia_i 到 bib_i 需要 tit_i

Fighting! 1036

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

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

CSU 1808 地铁(拆点最短路)

1808: 地铁 Time Limit: 5 Sec  Memory Limit: 128 MB Submit: 728  Solved: 171 [Submit][Status][Web Board] Description  Bobo 居住在大城市 ICPCCamp。 ICPCCamp 有 n 个地铁站,用 1,2,…,n 编号。 m 段双向的地铁线路连接 n 个地

TUT我好菜啊 844

visio安装包

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

CSU 1808 地铁(Dijkstra变形+构图)

据说是叉姐出的题?!         还是比较有意思的,在普通最短路上加上了一个几号线之间的换乘费用。普通的最短路貌似解决不了了,因为很容易构造出一组数据,在不管几号线的时候的最短路和考虑这些的最短路不同,且点都不一样。那么怎么做呢?

alpc_qleonardo 901

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

最短路 csu1808 地铁

传送门: 题意:告诉你很多条地铁线路,问最短路。 思路:首先我们考虑到d[pre][u]表示,从pre到达u时的最短路。 这种做法正确性是显然的,问题是肯定会炸。但是看到u的pre不可能是所有节点。 这也暗示了拆点,如果一个点按照被连的边,拆成几个点,然后再跑最短路。 由于最多只有m条边,所以拆点以后也最多只有2m个点。 #include #include #include #i

qwb的博客 1310

CSUOJ 1808 地铁(最短路)

1808: 地铁 Description Bobo居住在大城市ICPCCamp。 ICPCCamp 有 n 个地铁站,用 1,2,…,n 编号。 m 段双向的地铁线路连接 n 个地铁站,其中第 i 段地铁属于 ci 号线,位于站 ai,bi 之间,往返均需要花费 ti 分钟(即从 ai 到 bi 需要 ti 分钟,从 bi 到 ai 也需要 ti 分钟)。 众所

nudt_oys的博客 1597

CSU 1808 地铁 2016湖南邀请赛 最短路 Dijkstra

CPCCamp 有 n 个地铁站,用 1,2,…,n 编号。 m 段双向的地铁线路连接 n 个地铁站,其中第 i 段地铁属于 ci 号线,位于站 ai,bi 之间,往返均需要花费 ti 分钟(即从 ai 到 bi 需要 ti 分钟,从 bi 到 ai 也需要 ti 分钟)。 众所周知,换乘线路很麻烦。如果乘坐第 i 段地铁来到地铁站 s,又乘坐第 j 段地铁离开地铁站 s,那么需要额外花费 |ci...

fnq9999的博客 196

CSU1808 地铁 —— dijkstra变形

题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1808 题解:待定…… 代码如下: #include #define LL long long #define maxn 200010 #define INF 1LL<<60 using namespace std; int n,m,vis[maxn],hea

A man can be destroyed, but not defeated. 766

CSU 1808 地铁(dijkstra+heap)

ICPCCamp 有 n 个地铁站,用 1,2,…,n 编号。 m 段双向的地铁线路连接 n 个地铁站,其中第 i 段地铁属于 ci 号线,位于站 ai,bi 之间,往返均需要花费 ti 分钟(即从 ai 到 bi 需要 ti 分钟,从 bi 到 ai 也需要 ti 分钟)。 众所周知,换乘线路很麻烦。如果乘坐第 i 段地铁来到地铁站 s,又乘坐第 j 段地铁离开地铁站 s,那么需要额外花费 |c

Miracle_ma的专栏 1745

CSU 1808 地铁(最短路)

题意:n个地铁站,m条线路,地铁站之间花费t时间,不属于同一条线路的地铁站需要“转站”,即加上一个额外花费w(w为线路代号的差值)。 求1到n的最短时间 思路:由于有转站的影响,可以考虑将地铁站拆点,权值是他们的差值,或者直接以边作为点也是可以的 #include using namespace std; const int maxn = 2e5+7; #define inf 1LL<

围巾的ACM博客 831

csu 1808 地铁 dijkstra + heap 解题报告

Description  Bobo 居住在大城市 ICPCCamp。 ICPCCamp 有 n 个地铁站,用 1,2,…,n 编号。 m 段双向的地铁线路连接 n 个地铁站,其中第 i 段地铁属于 ci 号线,位于站 ai,bi 之间,往返均需要花费 ti 分钟(即从 ai 到 bi 需要 ti 分钟,从 bi 到 ai 也需要 ti 分钟)。 众所周知,换乘线路很麻烦。

小夥的博客 612

csu1808 地铁

终于把这道题补了,,拖了一个学期了,一直懒得去补。。 题目连接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1808 比普通的最短路,就是多了个换乘的花费,很自然的用  d[n][pre]代表从pre这条路到n这个点的最小时间花费,但第二维需要开多大那?d[1e5][1e5]?显然会爆,,因为有很多路是用不到的,所以又会很自然的想到,,可以

我们做的队 528

csu 1808 地铁 dijkstra变形+优先队列优化

1到每个点的最短时间,不仅与到相邻点的最短距离有关,而且与地铁的换乘有关. 如果用dp[ni][ci]保存数据(ni地铁站点,ci地铁班次) dp[from][ci]=min(dp[from][ci],dp[to][ci2]+abs(ci-c i2)+cost[to][from]),内存使用不理想; 所以可以保存(从1出发,最后走过这条边的最短时间); 每条边建立时可以保存对应的c,t;再利用di

vvv_557的博客 360

csu 1808 地铁 拆点最短路

对于每一条不同的地铁线路进行拆点,生成新的节点,连边,然后对于同一地铁站内的不同节点按照他们所属的地铁线的编号从小到大连接,最后跑最短路,建图是难点,我们可以对同一地铁线的不同边进行统一处理,同时再依次添加到相应的地站的集合中,因为是顺序插入,所以本身就是从小到大的了,具体见代码。 #include #include #include #include #include #includ

熟睡的哲学家的博客 504
上一篇: 牛客练习赛43 F Tachibana Kanade Loves Game 容斥
下一篇: 2019西北工业大学程序设计创新实践基地春季选拔赛(重现赛)
CaprYang
博客等级 码龄8年 148粉丝 277原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值