zoj 3946 Highway Project

别再踩坑了!CAPL脚本里局部变量和全局变量的那些“怪事”(附CANoe实测代码) 本文深度解析CAPL脚本中局部变量和全局变量的特殊机制,揭示其与通用编程语言的差异。通过实测代码展示静态局部变量的默认行为和全局变量的节点隔离特性,并提供高效避坑指南,帮助汽车网络测试工程师避免常见陷阱。 阅读详情

Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he proposed the highway project.

The Marjar Empire has N cities (including the capital), indexed from 0 to N - 1 (the capital is 0) and there are M highways can be built. Building the i-th highway costs Ci dollars. It takes Di minutes to travel between city Xi and Yi on the i-th highway.

Edward wants to find a construction plan with minimal total time needed to reach other cities from the capital, i.e. the sum of minimal time needed to travel from the capital to city i (1 ≤ i ≤ N). Among all feasible plans, Edward wants to select the plan with minimal cost. Please help him to finish this task.

Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first contains two integers N, M (1 ≤ N, M ≤ 105).

Then followed by M lines, each line contains four integers Xi, Yi, Di, Ci (0 ≤ Xi, Yi < N, 0 < Di, Ci < 105).

Output
For each test case, output two integers indicating the minimal total time and the minimal cost for the highway project when the total time is minimized.

Sample Input
2
4 5
0 3 1 1
0 1 1 1
0 2 10 10
2 1 1 1
2 3 1 2
4 5
0 3 1 1
0 1 1 1
0 2 10 10
2 1 2 1
2 3 1 2
Sample Output
4 3
4 4

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+7,INF=0x3f3f3f3f;
struct node
{
    ll v,c,d;
};
vector<node> q[N];
bool vis[N];
ll dis[N],tim[N];
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,m;
        scanf("%d%d",&n,&m);
        for(int i=0; i<n; i++)
            q[i].clear(),dis[i]=1e15,tim[i]=1e15,vis[i]=false;
        for(int i=0; i<m; i++)
        {
            ll x,y;
            ll c,d;
            scanf("%lld%lld%lld%lld",&x,&y,&d,&c);
            q[x].push_back({y,c,d});
            q[y].push_back({x,c,d});
        }
        dis[0]=0;
        tim[0]=0;
        queue<int> que;
        que.push(0);
        vis[0]=true;
        while(!que.empty())
        {
            int cur=que.front();
            que.pop();
            vis[cur]=false;
            for(int i=0; i<q[cur].size(); i++)
            {
                int s=q[cur][i].v;
                ll ci=q[cur][i].c,di=q[cur][i].d;
                if(dis[s]>dis[cur]+di||(dis[s]==dis[cur]+di&&tim[s]>ci))
                {
                    dis[s]=dis[cur]+di;
                    tim[s]=ci;
                    if(!vis[s])
                    {
                        que.push(s);
                        vis[s]=true;
                    }
                }
            }
        }
        ll ans=0,ti=0;
        for(int i=0; i<n; i++)
        {
            ans+=dis[i];
            ti+=tim[i];
        }
        printf("%lld %lld\n",ans,ti);
    }
}
6、高通8155座舱平台--摄像头系统 在项目中遇到过,很多从手机转过来的工程师,上来就按手机那套调Camera,结果发现根本跑不通——为什么?我踩过这个坑——一开始想靠软件打时间戳来对齐,结果发现两个sensor的曝光时间不一样,时间戳根本对不上。我记得第一次调AWB时,怎么调颜色都不对,后来发现是BLC的参数没配好——黑电平偏了,后面所有颜色校正都是错的。上层应用说「我要拍张照」,HAL把它翻译成「ISP你给我处理这帧数据,sensor你给我曝光一次」。8155上推荐用camx,它是高通新一代的Camera框架,性能更好,而且支持多路同步。 阅读详情

相关推荐

《IC验证必看|IC验证的全流程概览(从DUT到回归交付)》

本文系统介绍了IC验证的全流程,从理解设计需求到最终交付验证结果。主要内容包括:1)深入理解DUT的功能和接口;2)制定详细的测试计划(Testplan);3)搭建UVM验证平台;4)执行定向和随机测试并进行回归;5)分析功能、代码和断言覆盖率;6)交付完整的验证报告。文章强调验证是一个闭环过程,特别指出新手容易忽视测试计划和覆盖率分析这两个关键环节,导致验证不充分。文末还提出思考题,引导读者反思验证计划的制定方法。

m0_46663240的博客 1272

ZOJ 3946 Highway Project(最小费用最短路,优先队列优化dijkstra)

ZOJ 3946 Highway Project Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he propos

No Rain,No L'Arc~en~Ciel 397

别再为3D抓取发愁了!Halcon手眼标定保姆级教程(Eye-to-Hand模式,含完整代码)

本文提供Halcon手眼标定的保姆级教程,详细讲解Eye-to-Hand模式下的3D抓取实现方法。从硬件配置、坐标系系统到标定流程和核心算法,涵盖完整代码和实战经验,帮助用户快速掌握工业自动化中的精准抓取技术。

weixin_42523711的博客 275

zoj 3946 Highway Project(最短路径)

题目链接 题意:最短路径,每个边上有2个权值,第二个权值是不能累加的#include<bits/stdc++.h>using namespace std;#define LL long long #define cl(a,b) memset(a,b,sizeof(a)) #define pb push_back #define gcd __gcdconst int maxn = 100005; c

qwesde 801

手把手教你用TUSB2E22中继器实现eUSB2与USB 2.0互转(附实测数据对比)

本文详细介绍了如何利用TUSB2E22中继器实现eUSB2与USB 2.0的高效互转,包括技术背景、硬件设计要点、信号完整性测试方法及故障排查策略。通过实测数据对比,展示了TUSB2E22在信号延迟、功耗和眼图性能上的显著优势,为工程师提供了实用的工程方案。

weixin_29199873的博客 290

Windows环境下DataEase一站式安装指南(含WSL2+Docker配置)

本文详细介绍了在Windows环境下通过WSL2和Docker快速部署DataEase的完整教程。从WSL2配置、Docker环境搭建到DataEase离线安装,逐步指导用户完成一站式部署,特别适合需要快速搭建数据分析平台的开发者。教程包含常见问题解决方案和性能优化技巧,帮助用户高效使用这款国产开源数据可视化工具。

weixin_42526166的博客 403

ZOJ 3946 Highway Project (spfa)

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5718Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as

我要加油了,因为我还有很多NB的梦想! 686

子图同构之乌尔曼算法Ullmann Algorithm的python实现

给定两个图Ga​(子图)和Gb​(原图),其中Ga​有pa​个点和qa​条边,Gb​有pb​个点和qb​条边,其邻接矩阵分别为A和B。子图同构的关键在于找到一种从Ga​的点到Gb​的点的映射MM是一个pa​行pb​列的矩阵,且满足每行只有一个1(表示Ga​中的一个点唯一地映射到Gb​中的一个点),每列至多一个1(确保Gb​中的点不会被重复映射)。定义Ccij​MMBT,若在图Ga​。

weixin_42822813的博客 1978

zoj-3946-Highway Project【13th浙江省赛】【最短路】

3946-Highway Project

Linoy 1568

ABAP 大规模数据并行处理实战,六套 Parallel Processing Framework 如何选,性能调优真正该盯住什么

如果今天真的面对那份执行 14 个小时的生产报表,我不会马上把原来的 Loop 改成 50 个aRFC。我会先用 SAT、ST12、SQL Monitor 和 HANA 侧工具确认时间到底花在哪里。如果 90% 时间其实消耗在一条低效 SQL 上,Parallel Processing 只是让 50 个 Worker 同时执行那条低效 SQL,数据库会比原来更痛苦。应该先把串行逻辑本身优化到合理水平。该做 Set-based Processing 的地方先交给 HANA。该避免SELECT。

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

vue3:实现ECharts3D地图详细示例,echarts实现3D地图map3D,vue3如何利用echarts绘制3d地图立体城市省市地区分布,可视化数据大屏3D炫酷中国地图(复制源码,开箱即用)

echarts实现中国地图记录篇之3D地图,Echarts地图之——如何让地图显示出3d感,【3d地图】vue中使用echarts geo3D,echarts实现某个市3D地图展示,vue3中使用echarts实现中国地图,3D地图图表,echarts实现3D地图——map3D,数据大屏3d地图,vue3+echarts绘制中国地图,3D地图,省、市、县,【3d地图】vue3中使用echarts geo3D,echarts实现某个市3D地图展示,ECharts3D地图(详细示例——附有具体注释),echar

✅ 精选推荐文章 3683

ZOJ 3946(单源最短路)

//题意:给定n个点,m条路,每条路的花费为d,消耗的时间为c // 求从起点到各个点的时间之和最小且花费最小 //方法:spfa跑一遍并维护cost 答案会爆int 有点坑 #include #include #include #include #define error 999999999 using namespace std; int fir[100100], vis

Below_Crusder的博客 621

大模型在电力交易功率预测中的应用:短期,超短期,中长期的完整解决方案代码详解

本文介绍了基于大模型的电力交易功率预测系统,该系统覆盖超短期(15分钟-1小时)、短期(1-6小时)和中长期(1天-1月)三个时间尺度。文章详细阐述了数据准备与特征工程,包括多源数据集成和特征重要性分析。在模型构建方面,采用了Temporal Fusion Transformer (TFT)模型进行超短期预测,Informer模型进行短期预测,以及N-HiTS模型进行中长期预测。此外,文章还探讨了概率预测与风险分析,并介绍了模型部署与交易策略集成的实现。最后,文章总结了系统的贡献,并展望了未来发展方向,如市

专注AI大模型,软件混淆,授权 1268

Highway Project (ZOJ - 3946,双权值 spfa)

一.题目链接: ZOJ-3946 二.题目大意: T 组数据. 第一行两个整数 n,m 之后 m 行数据,每行给出第 i 条路的 {起点,终点,花费时间,花费金钱} 首都为第 0 号城市. 求从首都到其他所有城市所需的 总时间 和 总建路花费. 三.分析: 双权值的单源最短路,更改 if 条件语句里就可以了. 注意:时间可重复加,但花费不可以. 所以直接用 dis2[v...

The___Flash的博客 306

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

ZOJ 3946 Highway Project

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3946 题意:有n个点(编号0~n-1),m条边的一个图,每条边都有权值和搭建这条边所需要的花费。现在从0号点出发,要使得它到其余点的路径和最小,而且在路径和最小的情况下,要求搭建边的花费最少。 思路:首先考虑一个点到其余点最短,可以用dijkstr

DS-K的博客 887

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

zoj3946 Highway Project

K. Highway Project t->测试数据组 n,m->n个点,m条可建边 x,y,d,c->x与y有可以建边,经过此边为d 时间,建边需c费用 #include <bits/stdc++.h> using namespace std;typedef long long ll; const int N=100005; const ll inf=1e12;struct no

u014445884的专栏 580

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

zoj3946--Highway Project

Highway ProjectTime Limit: 2 Seconds Memory Limit: 65536 KB Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the...

dixi7825的博客 197

ZOJ - 3946 Highway Project

Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he proposed the highway project. The...

yhb的博客 163

zoj3946 Highway Project

Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he proposed the highway project. The

zoey的博客 277

ZOJ 3946 Highway Project(最短路)

题目链接:http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3946 题面: Highway Project Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, the emperor of the Marjar Empire, wan

David_Jett 1156

ZOJ 3946 Highway Project 优先队列dijk

Highway Project Time Limit: 2 Seconds Memory Limit: 65536 KB Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other citie...

184

ZOJ3946-Highway Project

Highway Project Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from th

wang_128的博客 520

ZOJ 3946 Highway Project(Dijkstra)

ZOJ 3946 Highway Project(Dijkstra)

Dacc123的博客 752

zoj3946 Highway Project 【最短路】

比赛的时候,以为是最短路+最小生成树,最后wa到死。 出来后才知道是最短路。#include<bits/stdc++.h> using namespace std; const int N=2e5+10; const long long inf=0x3fffffffffffffff; struct node { int u,v; long long d,c; } G[N]; vec

禅境花园 592

zoj 3946 Highway Project【SPFA多个性质的最优化】

Highway Project Time Limit: 2 Seconds      Memory Limit: 65536 KB Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from t

dxx_111的博客 789
上一篇: pta 家庭房产
下一篇: CodeForces 676C Vasya and String
oinei
博客等级 码龄10年 9粉丝 73原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值