hdu2923

AMD锐龙笔记本隐藏玩法:分核降压+ PBO2超频全攻略(以5900HX/6900HX为例) 本文详细解析了AMD锐龙笔记本(以5900HX/6900HX为例)的分核降压与PBO2超频技术,帮助用户释放处理器隐藏性能。通过BIOS设置、Curve Optimizer参数调整及稳定性测试,实现性能提升与温度控制的完美平衡,适合硬件爱好者进阶调校。 阅读详情

Einbahnstrasse

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1331    Accepted Submission(s): 364


Problem Description
Einbahnstra   e (German for a one-way street) is a street on which vehicles should only move in one direction. One reason for having one-way streets is to facilitate a smoother flow of traffic through crowded areas. This is useful in city centers, especially old cities like Cairo and Damascus. Careful planning guarantees that you can get to any location starting from any point. Nevertheless, drivers must carefully plan their route in order to avoid prolonging their trip due to one-way streets. Experienced drivers know that there are multiple paths to travel between any two locations. Not only that, there might be multiple roads between the same two locations. Knowing the shortest way between any two locations is a must! This is even more important when driving vehicles that are hard to maneuver (garbage trucks, towing trucks, etc.)

You just started a new job at a car-towing company. The company has a number of towing trucks parked at the company's garage. A tow-truck lifts the front or back wheels of a broken car in order to pull it straight back to the company's garage. You receive calls from various parts of the city about broken cars that need to be towed. The cars have to be towed in the same order as you receive the calls. Your job is to advise the tow-truck drivers regarding the shortest way in order to collect all broken cars back in to the company's garage. At the end of the day, you have to report to the management the total distance traveled by the trucks.
 

Input
Your program will be tested on one or more test cases. The first line of each test case specifies three numbers (N , C , and R ) separated by one or more spaces. The city has N locations with distinct names, including the company's garage. C is the number of broken cars. R is the number of roads in the city. Note that 0 < N < 100 , 0<=C < 1000 , and R < 10000 . The second line is made of C + 1 words, the first being the location of the company's garage, and the rest being the locations of the broken cars. A location is a word made of 10 letters or less. Letter case is significant. After the second line, there will be exactly R lines, each describing a road. A road is described using one of these three formats:


A -v -> B
A <-v - B
A <-v -> B


A and B are names of two different locations, while v is a positive integer (not exceeding 1000) denoting the length of the road. The first format specifies a one-way street from location A to B , the second specifies a one-way street from B to A , while the last specifies a two-way street between them. A , ``the arrow", and B are separated by one or more spaces. The end of the test cases is specified with a line having three zeros (for N , C , and R .)

The test case in the example below is the same as the one in the figure. 

 

Output
For each test case, print the total distance traveled using the following format:


k . V


Where k is test case number (starting at 1,) is a space, and V is the result.
 

Sample Input
  
4 2 5 NewTroy Midvale Metrodale NewTroy <-20-> Midvale Midvale --50-> Bakerline NewTroy <-5-- Bakerline Metrodale <-30-> NewTroy Metrodale --5-> Bakerline 0 0 0
 

Sample Output
  
1. 80
 

Source
 

Recommend
lcy
 


两次dijkstra即可

#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#define inf 99999999
using namespace std;
int m[105][105];
char t1[50];
char t2[50];
int num[1005];
int d[105];
int n;
void dijkstra()
{
    int vis[105];
    int i;
    for(i=1;i<=n;i++)
        d[i]=inf;
    d[1]=0;
    memset(vis,0,sizeof(vis));
    for(i=1;i<=n;i++)
    {
        int mm=inf,x,y;
        for(y=1;y<=n;y++)
        {
            if(!vis[y]&&d[y]<mm)
                mm=d[x=y];
        }
        vis[x]=1;
        //printf("%d",x);
        for(y=1;y<=n;y++)
        {
            if(m[x][y]!=-1&&d[y]>d[x]+m[x][y])
                d[y]=d[x]+m[x][y];
        }
    }
}
void tran()
{
    int i,j;
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            int t=m[i][j];
            m[i][j]=m[j][i];
            m[j][i]=t;
        }
    }
}
int main()
{
    int c,r;
    int cas=0;
    while(scanf("%d%d%d",&n,&c,&r))
    {
        if(n==0&&c==0&&r==0)
            break;
        int i;
        cas++;
        memset(m,-1,sizeof(m));
        map<string,int> map;
        char car[50];
        int k=1;
        for(i=0;i<c+1;i++)
        {
            scanf("%s",car);
            if(map[car]==0)
                map[car]=k++;
            num[i]=map[car];
        }
        char a1,a2,a3,a4;
        int w;
        for(i=0;i<r;i++)
        {
            cin>>t1>>a1>>a2>>w>>a3>>a4>>t2;
            if(map[t1]==0)
                map[t1]=k++;
            if(map[t2]==0)
                map[t2]=k++;
            int u=map[t1];
            int v=map[t2];
            if(a1=='<'&&(m[v][u]==-1||m[v][u]>w))
                m[v][u]=w;
            if(a4=='>'&&(m[u][v]==-1||m[u][v]>w))
                m[u][v]=w;
        }
        int j;
        int res=0;
        dijkstra();
        for(i=0;i<c+1;i++)
            res+=d[num[i]];
        tran();
        dijkstra();
        for(i=0;i<c+1;i++)
            res+=d[num[i]];
        printf("%d. %d\n",cas,res);
    }
    return 0;
}


【上海大学计算机组成原理实验报告】七、程序转移机制 学习实现程序转移的硬件机制//掌握堆栈寄存器的使用//手动方式实现子程序调用转移过程//手动方式实现子程序返回转移过程//编程实现`OUT`寄存器交替显示`11`和`55`//若要求`11`和`55`各显示`50`次后停机,应该如何修改程序?//根据实验指导书的相关内容,实验箱系统的程序转移硬件机制在于,当`LDPC`有效时,如果此时`DUBS`上的值就是转移的目标地址,则此目标地址被打入`PC`,从而实现程序的转移;若`LDPC`为`0`是附带条件的,就形成“条件转移”。 阅读详情

相关推荐

k8s中如何使用gpu、gpu资源讲解、nvidia gpu驱动安装

gpu资源也是服务器中常见的一种资源,gpu即显卡,一般用在人工智能、图文识别、大模型等领域,其中nvidia gpu是nvidia公司生产的nvidia类型的显卡,amd gpu则是adm公司生产的amd类型gpu。企业中服务器最常见的就是英伟达gpu服务器了。本篇也主要讲解英伟达驱动相关的知识。

MssGuo的博客 1万+

HDU2923:Einbahnstrasse(Floyd)

Problem Description Einbahnstra  e (German for a one-way street) is a street on which vehicles should only move in one direction. One reason for having one-way streets is to facilitate a smoother f

ACM!荣耀之路! 2840

基础的pdf病毒木马

基础的pdf病毒木马 环境: 攻击机:Kali 目标操作系统:Windows 10或Windows 7 (关闭防火墙和安全软件) 目标软件:Adobe Reader 8.1.2 msf框架搜索:adobe-pdf 1.打开msfconsole 2.搜索 adobe_pdf模块 3.加载攻击模块并设置payload 4.运行生成pdf 5.将pdf拖入到win10 6.打开msf,加...

小小猪的博客 4634

HDU 2923 Einbahnstrasse(两种方法)

Problem Description Einbahnstra e (German for a one-way street) is a street on which vehicles should only move in one direction. One reason for having one-way streets is to facilitate a smoother flow

他说少年如歌 553

SRRC型号核准的模块豁免规则解析——如何利用完整型模块简化设备认证流程

本文详细解析了SRRC型号核准中模块豁免规则的应用,重点介绍了完整型模块的技术定义、豁免条件及实际应用场景。通过合理利用完整型模块,企业可显著简化设备认证流程,缩短上市周期并降低成本。文章还提供了模块选型指南和常见问题解决方案,帮助工程师高效应对SRRC认证挑战。

weixin_29306011的博客 951

MATLAB 2022b 用户专属:保姆级IPOPT求解器安装配置全流程(含OPTI工具箱)

本文为MATLAB 2022b用户提供IPOPT求解器的详细安装与配置指南,涵盖OPTI工具箱的适配安装、环境变量设置及常见问题解决方案。通过实战案例演示非线性优化问题的求解过程,帮助用户高效部署这一强大的优化工具,提升工程计算效率。

weixin_29092031的博客 413

HDU-2923-Einbahnstrasse

ACM模版描述 题解好长的英文题,看得我都心碎了~~~百度了一下大意: 三个数字n、c、r,n代表城市的个数,c代表损坏的车辆的数量,r代表有几条路,然后接下去有c+1个字符串,第一个代表拖车公司的所在地,后面的c个地点表示损坏的需要拖回来的车辆所在地。在接下去r个字符串,代表r条路,左右为两个城市名,中间的一串字符中,只含有<-代表该条路是从右边的城市通向左边的,以此类推,而数字代表该条路的长

逐梦者 546

uniApp微信小程序:利用live-pusher人脸活体检测功能+完整示例代码,uniapp使用live-pusher直播推流组件实现人脸验证-活体检测,检测人脸中的动作包括眨眼、张嘴、左右摇头动作

UniApp 使用 live-pusher 实现人脸活体检测(附完整源码)uniapp开发微信小程序人脸检测活体检测,在uni-app的微信小程序项目中使用live-pusher实现人脸识别,uniapp使用live-pusher实现模拟人脸识别效果,张张嘴、眨眨眼、向左摇头、向右摇头等动作,免费使用人脸活体检测的插件方案,uniapp小程序怎么免费使用人脸活体,直播推流,UNIAPP微信小程序使用live-pusher实现人脸识别(拍照)功能,在uni-app项目中实现人脸识别,既使用uni-app中的l

✅ 精选推荐文章 3026

hdu 2923

最短路加字符串处理 #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <cstring> #include <cstdlib> #include <map> using...

weixin_30763397的博客 158

OPC UA协议深度解析 + C#跨平台实战:无缝对接西门子S7-1200/1500 PLC

本文完成了OPC UA协议深度解析→西门子PLC服务端配置→C#跨平台客户端开发→全平台部署拆解OPC UA核心模型与安全机制,从原理层面理解工业标准化通信逻辑基于官方SDK开发工业级客户端,支持读写、订阅、证书管理、心跳保活核心功能实现Windows、Linux、统信UOS全平台兼容,满足工控系统国产化改造刚需提供完整的优化方案与踩坑指南,可直接落地商用项目。

这里只有干货:从 Modbus 到 MES,从 YOLO 到工控机部署;65 篇现场排障案例,每篇都写到改哪一行。 536

多物理场光学仿真软件:COMSOL_(10).激光器与谐振腔仿真

定义Nd:YAG晶体的材料属性% 折射率% 吸收系数% 发射截面% 定义光泵浦源% 泵浦光波长% 泵浦光强度% 泵浦光方向% 定义全反射镜% 选择边界% 完美电导体边界条件% 定义部分反射镜% 选择边界% 反射率边界条件% 反射率通过 COMSOL 对激光器和光学谐振腔进行仿真,可以全面评估激光器的性能,包括输出功率、效率、稳定性和模式选择等。这些仿真结果为激光器的设计和优化提供了重要的参考依据。

kkchenjj的博客 1667

Hdu 2923(最短路)

hdu 2923 思路: 从修理厂到各个修车地点的距离L1,然后再到修理厂L2,总共c辆坏车, 求∑(L1+L2)的最小值, 可以先正项建图,求出修车厂到各个坏车点的距离L1, 然后逆向建图,求出坏车点到修车厂的最小距离。 注意: (1)有重边,用邻接表不用考虑,临街矩阵要保证每条边最短 (2)输出的格式,特判时也要注意格式。 #include<iostre...

积少成多,水滴石穿 260

YOLOv13优化Faster_Block:卷积(Partial Convolution)、多层感知机(MLP)结构和残差连接

Faster_Block 代表了现代深度学习中效率与性能平衡的一个典型案例。它通过部分卷积技术巧妙地减少了计算开销,同时通过精心设计的架构保持了强大的特征学习能力。这种设计思想对于移动端部署、实时应用和大规模模型训练都具有重要意义。 未来的发展方向可能包括更智能的动态分割策略、与新兴硬件的深度适配,以及与其他先进技术(如自注意力机制、神经架构搜索等)的结合。Faster_Block 的成功展示了在深度学习领域,创新往往来自于对问题本质的深刻理解和巧妙的工程实现。

FJN110的博客 433

hdu 2923Einbahnstrasse(spfa/floyd+map)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2923 题目意思:有n个城市,城市是用字符串表示的,c个城市有坏的车,r条有向有权道路,求从你在所在的城市,将坏的车拖回来的花费。 思路:思路蛮简单,就是用map将城市(字符串)转化成编号,再求最短路,就是map处理稍微复杂点。 开始我没仔细看数据大小,用spfa做的,代码量...

agyohust791263的博客 230

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

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

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

hdu 2923 Einbahnstrasse

点击打开链接hdu 2923 思路:最短路+SPFA / 最短路+floyd 分析: 1 题目要求的是有n个点,然后有c个破车,这个c个破车可能在同一城市里面,现在要把这些破车统一拉到中心点1. 2 这题的中心在1点,那么所求 ans = 1-&gt;所有破车的距离之和 + 所有破车-&gt;1的之和。所以这里涉及到1-&gt;所有破车的距离 和 所有破车-&gt;1的距离,那么我们可...

我是传奇 177

inori mmd 7z

楪祈的模型资源....................................................................................................................................................................................................................

HDU - 2923 Einbahnstrasse 【floyd】

点击打开链接 题意(此题最难部分!) :  给你呢个城市,给你c辆坏车,给你坏车的城市,然后给你路径。 求最短费时,一次只能拖一辆。 题解:  floyd 跑一遍,只要是读入可能看着很烦人。 注意有重边 竟然把sum,c,ca,x,y定 义成 char   答案还对。 wa到爆炸。   #include #include using names

zoro_n的博客 363

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

HDU-2923-Einbahnstrasse(map+反向建图)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2923 题意:给你三个数 n, c, r,分别代表n 个地点(包括公司的车库地点和车抛锚的地点),c 表示c辆车抛锚的地点, r 条道路 第二行给出 c+1 个地点,第一个为车库地点, 其余的 c 个为车抛锚的地点。 接下来的 r 行表示 r 条有向的道路(一共有三种形式): A--V-&gt;...

sugarbliss 409

Hdu 2923 MAX Average Problem (DP_斜率优化)

Hdu 2923 MAX Average Problem (DP_斜率优化) 分类: 全部博客 ACM_好题经典题 ACM_动态规划(DP)2012-08-22 00:33 336人阅读 评论(0) 收藏 举报 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2993 题目大意:给定一个长度为n的序列,从其中找

pi9nc的专栏 763

HDU 2923 Einbahnstrasse

题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2923EinbahnstrasseTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3780 Accepted Submiss

moonlight的博客 314

hdu2923—Einbahnstrasse(spfa)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2923 Einbahnstrasse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3591    Accepted Subm

zhiyuanjiang的博客 382

HDU 2923

//这两天做的最短路,基本上都和字符串扯上关系了,都要用map容器,尤其是这题,写起代码来有点耗时间, //而且要注意的细节特别多,只要多刷刷这样的题目,下次看到这样的题目,就不会那么 //害怕了,知道一步一步来,用map来解决问题! // // // #include #include #include #include #include #include using names

傻笨 579

HDU 2923 Einbahnstrasse(Floyd)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2923 题目大意:你需要将C个车库的若干辆破车用拖车拖去公司,司机是一位娴熟的老司机,因此他知道如何走才能使总路程最短,而你需要做的就是输出这个最短路径。这道题我们需要注意的是它两个点之间是可能有重边的,而且这道题目还有一个隐藏条件,你每次用拖车将破车拖至公...

asdfghjkl999999999的博客 178

hdu 2923 Floyd The shortest route

Be Attention ,These is may be a  locality has more than one broken-car .Clearly,Floyd is simple than Dijkstra in this problem. The portal:http://acm.hdu.edu.cn/showproblem.php?pid=2923 /************

NM的专栏 541

HDU 2923 Einbahnstrasse

链接: http://acm.hdu.edu.cn/showproblem.php?pid=2923 题目: Einbahnstrasse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1117    Ac

D_Double's Journey 1212
上一篇: hdu1546 dijkstra
下一篇: hdu 3339 最短路+01背包
JustSteps
博客等级 码龄14年 48粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址