[最短路spfa]pku1511-Invitation Cards

手把手教你用Arduino Uno控制meArm机械臂(附完整代码+避坑指南) 本文提供了一份详尽的meArm机械臂控制指南,涵盖从Arduino Uno硬件连接到Servo库编程的完整流程。重点讲解了如何通过独立供电、软件限位和平滑运动函数实现稳定控制,并设计了串口指令协议与高级功能,帮助创客有效规避舵机抖动、电源不足等常见问题,让机械臂运行更流畅可靠。 阅读详情

http://acm.pku.edu.cn/JudgeOnline/problem?id=1511

 

Invitation Cards
Time Limit: 8000MS Memory Limit: 262144K
Total Submissions: 5784 Accepted: 1616

Description

In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They have printed invitation cards with all the necessary information and with the programme. A lot of students were hired to distribute these invitations among the people. Each student volunteer has assigned exactly one bus stop and he or she stays there the whole day and gives invitation to people travelling by bus. A special course was taken where students learned how to influence people and what is the difference between influencing and robbery.

The transport system is very special: all lines are unidirectional and connect exactly two stops. Buses leave the originating stop with passangers each half an hour. After reaching the destination stop they return empty to the originating stop, where they wait until the next full half an hour, e.g. X:00 or X:30, where 'X' denotes the hour. The fee for transport between two stops is given by special tables and is payable on the spot. The lines are planned in such a way, that each round trip (i.e. a journey starting and finishing at the same stop) passes through a Central Checkpoint Stop (CCS) where each passenger has to pass a thorough check including body scan.

All the ACM student members leave the CCS each morning. Each volunteer is to move to one predetermined stop to invite passengers. There are as many volunteers as stops. At the end of the day, all students travel back to CCS. You are to write a computer program that helps ACM to minimize the amount of money to pay every day for the transport of their employees.

Input

The input consists of N cases. The first line of the input contains only positive integer N. Then follow the cases. Each case begins with a line containing exactly two integers P and Q, 1 <= P,Q <= 1000000. P is the number of stops including CCS and Q the number of bus lines. Then there are Q lines, each describing one bus line. Each of the lines contains exactly three numbers - the originating stop, the destination stop and the price. The CCS is designated by number 1. Prices are positive integers the sum of which is smaller than 1000000000. You can also assume it is always possible to get from any stop to any other stop.

Output

For each case, print one line containing the minimum amount of money to be paid each day by ACM for the travel costs of its volunteers.

Sample Input

2
2 2
1 2 13
2 1 33
4 6
1 2 10
2 1 60
1 3 20
3 4 10
2 4 5
4 1 50

Sample Output

46
210

Source

题目大意:给出一个有向图和起点,求其他所有点到这个点的最短路和这个点到其他点的最短路的总和。
分析:因为数据规模很大,所以用dijkstra会超时,考虑到边不是特别多,所以选择用spfa。如果枚举每个点作为起点求它到1的距离的话,效率太低,会超时。其实,只要把图中的边都反过来,再求一次单源最短路就可以了。
我用的是静态链表。
codes:
VisionPro - 基础 - 模板匹配技术-Search/PMAlign/PatMax(6)-纹理屏蔽和重叠匹配 Note:对已经有了,1已经训练好的模板,2一组使能的自由度,3一个待测的实时图片,PatMax 就能模板匹配的给出变化的最佳描述。对一些综合的模板,这三个输入值往往是一起影响最后的变换结果信息。例如,如果我们训练了一个圆形的模板,然后搜索一个角度自由度包括一个圆,那么将会有无限个可能的角度满足要求。这些组合的模板匹配,被官方名为:退化系统,a degenerate system的结果被叫做a degenerate result 退化结果4.2 退化系统例子。 阅读详情

相关推荐

SAP-ABAP:SAP中如何查看系统表之间的关联关系?

在业务逻辑开发或者ALV开发过程中,我们通常要从系统中找出几个标准表之间的关联关系,有的是head与item,通过外键进行关联的关系。那么怎么去找到呢?以上就是具体如何产看系统表之间的关联关系的步骤,对于不同代码的业务顾问,也是必须要掌握的。

LinkStar的博客 2433

HDU1535 Invitation Cards(链式前向星+堆优化dijkstra)[C++]

目录题目及翻译题面输入输出输入样例输出样例题目思路注意事项AC代码C++ 题目及翻译 题面 In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate the...

扶她小藜 645

ANSYS Fluent中的声学模型:实用指南

文章摘要 本文介绍了ANSYS Fluent中三种气动声学模拟方法:Ffowcs-Williams & Hawkings(FWH)模型、宽带噪声源模型和波动方程模型。FWH模型适用于外部气动声学问题,需要瞬态流场数据来预测远场噪声;宽带模型基于稳态RANS模拟,可快速识别噪声源位置,适合早期设计阶段;波动方程模型直接求解声波方程,提供全域声压分布,但仅适用于低马赫数流动。文章详细说明了各模型的使用场景、设置步骤和关键参数配置,为工程应用提供了实用指南。

weixin_45793544的博客 1332

最短路dijkstra—Invitation Cards(POJ-1511)

题目链接:>_> 题目:Invitation Cards In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, m...

Darge. 289

【文献阅读笔记】之基于注意力机制的深度学习路面裂缝检测

中文,计算机辅助设计与图形学学报,第 32 卷 第 8 期,2020 年 8 月。 DOI: 10.3724/SP.J.1089.2020.18059 摘要: 为实现自动准确地检测路面裂缝, 提升路面裂缝检测效果, 提出了一种基于注意力机制的裂缝检测网络 (attention-based crack networks, ACNet). 该网络采用编码器-解码器网络构架, 编码器采用 ResNet34 为骨干网, 提取路面裂缝特征; 在编码器和解码器间加入基于注意力机制的特征模块(attention-b

qq_44785998的博客 7596

【汽车故障诊断2】从标准到实战:解码DTC格式背后的诊断逻辑

本文深入解析汽车诊断故障码(DTC)的格式与逻辑,对比了OBD-II标准(如ISO 15031-6)的5字符格式与UDS协议(ISO 14229-1)下更丰富的3字节格式。文章从国际标准出发,结合实战案例,阐述了DTC如何作为汽车电子系统的“体检报告”,帮助工程师和维修技师精准定位故障,并详细解读了UDS 19服务如何读取和管理DTC状态。

berry的博客 717

HDU - 1535 Invitation Cards

题目: In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. T...

qq_41998938的博客 192

Ubuntu18.04安装VCS、Verdi、dve全套教程亲测(有成功截图)

通过下面十个步骤,我们就可以在ubuntu上使用vcs、verdi、dve等软件! 一、安装ubuntu系统,这个不在这里讲了,重点叫安装VCS、Verdi等软件 下面的过程一部分同其他网上流程一致,对其中部分进行修改。如果按照其他网上教程是不会成功的,本人亲测,下面是我试验网上不同文章的流程遇到的错误摸索后总结的流程,按照步骤保证可以成功运行,包括破解流程,使用时间不限制在2020年,可以自定义2030等等。 二、安装文件结构 –synopsys_installer #此程序用于安装下面三个程序。所以你想

QQ_778132974的博客 6369

hdu 1535 Invitation Cards(spfa)

小记:这题还是要理解了题意就好做了

ljd4305的专栏 993

在 SAP BTP 上为应用开启多租户能力:基于 SaaS Provisioning 和 XSUAA 的完整实践指南

本文介绍了在SAP BTP上配置多租户应用的实战指南。主要内容包括: 多租户架构概述:解释provider子账户、consumer子账户和tenant的概念,以及数据隔离机制。 安全配置:在xs-security.json中设置tenant-mode为shared,并为SaaS Provisioning服务添加回调scope授权。 路由配置:通过manifest.yml设置TENANT_HOST_PATTERN来定义多租户访问模式,确保不同租户通过不同子域名访问同一应用。 服务绑定:将XSUAA和SaaS

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

SRS流媒体服务器在Windows下的安装

在之前的流媒体开发中(视频会议),我基本上使用nginx加模块的方式进行学习、测试,正式开发的时候改为服务器端用EasyDarwin,客户端用rtsp-simple-server(这些流媒体服务器的用法见我以前的博文),这样可以充分利用客户端的资源,降低服务器端的压力。在流媒体协议方案,我选择相对较快的rtsp。这个协议优点是支持UDP协议,优化好的环境下可以实现3秒以下的延迟,基本满足甲方要求,缺点就是不支持网页播放。

dgnankai的专栏 2027

poj 3259 Bellman-ford + SPFA

Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 43809   Accepted: 16085 Description While exploring his many farms, Farmer John has discovered a

转角的守望 505

2024年厦门市第31届小学生C++信息学竞赛(复赛)试题与解析(编程题二、战线巡逻(patrol))

2024年厦门市第31届小学生C++信息学竞赛(复赛)试题与解析(编程题二、战线巡逻(patrol))

汉克老师的博客 270

【图论】【最短路】 pku1511 Invitation Cards

【题目】:Invitation Cards【类型】:图论【难度】:中等【来源】:pku1511【关键字】:SPFA【题目大意】:给N个点的路径信息,给定一个点作为起点,求该点到每个点再回来总路程最小值。 --------------------------------------------------------------------------------------

mofixroot的专栏 604

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

pku 1511 Invitation Cards

一道好题,练习静态表(邻接矩阵的数组开不下),没写过静态表,参考http://www.cnblogs.com/cykun/archive/2011/01/19/1939542.html 写的,改用stl的queue写了。 思路比较简单,有向边建立的静态表要注意反向处理,然后把1到各点和各点到1的距离求和即可:spfa+静态表 #include <iostream>#in...

difu7962的博客 163

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

pku 1511 - invitation cards (spfa)

http://acm.pku.edu.cn/JudgeOnline/problem?id=1511题目描述:求出顶点1到其它n-1个点的最短往返路径长度和!路径的往返要分开处理。1:对于“往”,只需对输入数据,构建邻接表,调用spfa函数求最短路径。2:对于“返”,对输入数据的边进行反向构建邻接表。再对顶点1求最短路径,即可求出返的最短路径和!由于数据太BT,顶点数达到1000

422

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

PKU1511(Invitation Cards)最短路径-邻接表+SPFA算法

/****************************************************** 题目大意: 弱菜英语又是渣渣,题意是对着测试数据连猜带蒙出来的; 在一个有向图中,要求顶点1到其他的所有顶点往返的总共的最小花费; 另外给出的数据量略大,顶点数和边数都是1000000的范围; 算法分析: 这是一个最短路径问题; 由于数据范围很大,用邻接矩阵和dijkstra很可能超时

始往流离,终彼成章。 1587

pku 1511 Invitation Cards (SPFA 和 dijkstra+优先级队列优化)

<br />简单的最短路题目,只需建两次图,分别调用单源最短路算法即可。<br /> <br />但是由于数据量较大,所以需要用邻接表存储,以及对普通算法进行些优化。<br /> <br />注意最后的求和需要用long long型变量存储<br /> <br />分别用SPFA  和  加了优先级队列的dijkstra写了一遍,效率差不多,用的STL的priority_queue,如果手写堆的话应该可以更快。<br /> <br />SPFA版本:1511Accepted33016K1750MSG++23

Hewie的专栏 1119

PKU 1511 Invitation Cards (SPFA+邻接表)

题目链接:点击打开链接         题目需要求从原点到所有点的最短距离之和和所有点到原点的最短距离之和,在求所有点到原点最短距离的时候用到了一个技巧:即把图反向,求原点到所有其他点的最短距离,这样用一次SPFA就可以将所有点到原点的最短距离求出来了。           另外也没什么好说的,纯SPFA。另外用优化到VlogE的dijkstra貌似也能过,有空的时候再写个。   代码如

Jackie_Zhu的专栏 1381

pku1511 Invitation Cards

http://poj.org/problem?id=1511 图论,最短路,SPFA 求所有点到1 1 #include <stdio.h> 2 #include <string.h> 3 #include <queue> 4 #define N 1000100 5 6 using namespace std; 7 8...

weixin_30469895的博客 104

pku 1151 Invitation Cards(单源最短路径 SPFA)

<br /> <br />http://acm.pku.edu.cn/JudgeOnline/problem?id=1511<br /> <br />题目大意:在有向图中有n个结点,求从开始结点S(题中默认为1)到各其它各结点的距离和dist1和其它各结点到起点S(1)的距离和dist2之和sum最小.<br /> <br />解题思路:这道题点跟边都非常的大,达到1000000,所以就不能用Dj算法啦(因为只会朴素的Dj),就用SPFA来做啦,构建两个邻接表,正向的list1,反向的list2。起点到其他

话别深秋 965

pku 1511 Invitation Cards(最短路径)

Invitation Cards Time Limit: 8000MS   Memory Limit: 262144K Total Submissions: 16309   Accepted: 5310 Description In the age of television, not many people attend theat

街角的花街糖 742

CSU-ACM2017暑期训练14-最短路 D - 输入量很大的模板题

D - 输入量很大的模板题In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Com

xiyue_jiang的博客 488

邻接表(邻接图)

1.题目引入: In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They have printed invitation cards with all the nec

weixin_52914088的博客 197

POJ 1511 邻接表+spfa

第一次用邻接表做题,第一次写spfa算法,,,。这道题就是用两次spfa,分别求正向图的最短路和反向图的最短路,结果相加就可以了。。题目: Invitation Cards Time Limit: 8000MS   Memory Limit: 262144K Total Submissions: 13090   Accepted: 4240

1163

POJ 1511 Invitation Cards //spfa

<br />Invitation CardsTime Limit: 8000MS Memory Limit: 262144KTotal Submissions: 8425 Accepted: 2617<br />DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want t

hqd_acm的专栏 1281
上一篇: [计算几何]Pku2079-Triangle
下一篇: [最短路]pku2387-Til the Cows Come Home
fstephen
博客等级 码龄18年 7粉丝 28原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值