HDU 2923 - Einbahnstrasse(floyd)

SWIPT技术(无线通信携能技术)的简介与架构——(后续补充无人机SWIPT方向) SWIPT一、SWIPT(无线通信携能)技术简介1.1、组成:1.2、与传统无线通信的区别:1.3、SWIPT 的集成接收器架构设计1、单独的接收器2、TS架构——时间开关(Time switching,TS)3、PS架构——功率分流(Power splitting,PS)4、天线开关接收器主要两种架构的区别参考文献SWIPT的发展 一、SWIPT(无线通信携能)技术简介 SWIPT(Simultaneous Wireless Information and Power Transfer )是各种WPT技术 阅读详情

Einbahnstrasse

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


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
 


==========================

对我来说难点在于输入和存储


#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>

using namespace std;
const int INF=0x3f3f3f;
int dis[111][111],cnt,w,n,c,r,vis[111],cas=0;
char str[111],str1[111],str2[111],c1,c2;
map<string,int>mp;

void floyd()
{
    for (int k=1;k<=n;k++)
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
}

int getIdx(char s[])
{
    map<string,int>::iterator it;
    it=mp.find(s);
    if (it!=mp.end()) return it->second;
    else return mp[s]=cnt++;
}

int main()
{
    while(~scanf("%d%d%d",&n,&c,&r))
    {
        if(n==0&&c==0&&r==0) break;
        mp.clear();
        memset(dis,INF,sizeof(dis));
        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++) dis[i][i]=0;
        cnt=1;
        int ans=0;
        scanf("%s",str);
        mp[str]=cnt++;
        for(int i=1;i<=c;i++)
        {
            scanf("%s",str);
            vis[getIdx(str)]++;
        }
        for(int i=0;i<r;i++)
        {
            scanf("%s%s%s",str1,str,str2);
            sscanf(str,"%c-%d-%c",&c1,&w,&c2);
            if(c2=='>') dis[getIdx(str1)][getIdx(str2)]=min(dis[getIdx(str1)][getIdx(str2)],w);
            if(c1=='<') dis[getIdx(str2)][getIdx(str1)]=min(dis[getIdx(str2)][getIdx(str1)],w);
        }
        floyd();
        /*for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
                cout<<dis[i][j]<<" ";
            cout<<endl;
        }*/
        for(int i=1;i<=n;i++)
        {
            if(vis[i]>0) ans+=(dis[1][i]+dis[i][1])*vis[i];
        }
        printf("%d. ",++cas);
        printf("%d\n",ans);
    }
    return 0;
}


【WRF-Chem教程-附录B】使用 MOZART 与WRF-Chem 使用MOZART与WRF-Chem 阅读详情

相关推荐

大众点评爬虫实战:如何用Python绕过反爬机制获取评论数据(附完整代码)

本文深入探讨了2024年使用Python进行大众点评数据采集的实战策略。文章详细解析了现代反爬机制的核心逻辑,并提供了从构建拟人化请求会话、应对动态内容与接口加密,到工程化实践(代理调度、状态持久化)的完整解决方案与代码示例,旨在帮助数据分析师稳健获取评论数据,用于后续的文本挖掘与商业洞察。

weixin_29084111的博客 1920

hdu2923

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

skyline 1132

WRF-Chem新手避坑指南:从chem_opt到emiss_opt,那些手册里没明说的参数配置实战

本文为WRF-Chem新手提供从chem_opt到emiss_opt的参数配置实战指南,解析官方文档中未明确的常见陷阱与解决方案。通过华北重霾案例,详细讲解化学机制选择、排放源配置及特殊参数组合的注意事项,帮助用户避开常见错误,提升模拟效率。

weixin_30897079的博客 279

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

Android 13 Hotseat定制化修改——001 hotseat布局方向

一.背景由于需求是需要自定义修改Hotseat,所以此篇文章是记录如何自定义修改hotseat的,应该可以覆盖大部分场景,修改点有修改hotseat布局方向,hotseat图标数量,hotseat图标大小,hotseat布局位置,hotseat图标禁止形成文件夹,hotseat图标禁止移动到Launcher...

Java_fenxiang的博客 1102

企业微信审批流开发避坑指南:从零搭建自定义审批模板(含完整代码)

本文为企业微信审批流开发提供了从零搭建自定义审批模板的完整指南。通过对比内置模板与自建引擎的优劣,详细阐述了利用企业微信开放API和自建应用实现高度灵活审批流程的方案。文章重点解析了前端JS-SDK安全调用、后端签名生成与回调处理的核心代码,并分享了流程引擎设计、安全加固及性能监控等实战经验,帮助企业开发者避开常见陷阱,构建贴合业务的自定义审批系统。

weixin_28358083的博客 967

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!荣耀之路! 2839

基于PLC的全自动洗衣机控制系统+控制程序

本设计使用PLC控制系统替换了传统的继电器控制系统,实现了全自动洗衣机在硬件方面的提升,丰富了全自动洗衣机在软件方面的功能,提高了全自动洗衣机的洗衣效率,基本可以满足用户的洗衣需求。

zzzz114231的博客 8956

HDU-2923-Einbahnstrasse

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

逐梦者 546

最优化方法与数学建模

在本篇博客中,我们将探讨最优化方法在数学建模中的应用。首先,我们将介绍几种常见的最优化方法,如梯度下降、牛顿法和遗传算法。接着,我们将详细阐述这些方法的原理和算法。最后,我们将通过一个数学建模案例,展示如何使用Matlab实现这些方法。本文旨在为大家提供一个清晰的思路,以便更好地理解和应用最优化方法。

YOLO 439

电子元件及其规格书的查找与理解

本内容收录:在电子开发或维修过程中,查找电子元件及其规格书心得体会,以及元件规格书的理解,系个人多年实战经验的系统梳理。内容着重介绍贴片元件代码反查型号的实用技巧,并以三款典型疑难元件为例,详述其完整查找过程与最终型号确认。

让你爱上电路设计 3991

hdu 2923

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

weixin_30763397的博客 158

一步步教你使用 NVIDIA 推出的全新GPU加速求解器 cuOpt:解锁超高效率的求解体验

未完成

Linshaodan520的博客 869

HDU - 2923 Einbahnstrasse 【floyd】

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

zoro_n的博客 362

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

HDU 2923 Einbahnstrasse(Floyd)

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

asdfghjkl999999999的博客 178

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

hdu 2923Einbahnstrasse(spfa/floyd+map)

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

agyohust791263的博客 230

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

HDU2923 Einbahnstrasse (最短路 floyd)

上题: 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 t

wjmwsgj的博客 317

hdu 2923 Einbahnstrasse【floyd】

Einbahnstrasse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3126    Accepted Submission(s): 974 Problem Description Einbahnstra  e (

mengxiang000000 611

HDU 2923 Einbahnstrasse 【Floyd+map】

EinbahnstrasseTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3803 Accepted Submission(s): 1217Problem Description Einbahnstra e (German

Be Like 643

PPT绘图导出PDF的三种方式:另存为、打印输出与图片合成

在文档处理与图形设计中,矢量图形导出PDF常面临字体丢失、线条错位、颜色偏差等问题。其原理在于不同导出路径对矢量效果(渐变、透明度、阴影)的解析与栅格化策略不同。合理选择导出方式能显著提升输出质量与工作效率,适用于技术文档、印刷交付、跨平台分享等场景。本文对比了另存为PDF、打印输出PDF、图片合成PDF三种方案,从参数调优到质量检查,帮助读者根据图形复杂度与用途选择最佳实践,确保PPT绘图导出PDF时保留矢量细节与视觉一致性。

weixin_34062469的博客 388

【floyd/要防重边】HDU 2923 Einbahnstrasse

[url]http://acm.hdu.edu.cn/showproblem.php?pid=2923[/url] [b][size=medium] 一开始题意理解错了……英语太水了 [color=green]要从公司开始按所给顺序把车拉回来,是一辆一辆车拖回来……这是常识……我竟然想着最后一堆车拖回来[/color] [img]http://dl.iteye.com/upload/att...

基德KID.1412 209

hdu-2923-Einbahnstrasse (floyd)

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 ...

wangtao的博客 235

hdu 2923 Einbahnstrasse(Floyd+map)

http://acm.split.hdu.edu.cn/showproblem.php?pid=2923题目大意: 给出城市数,破车数和道路数,然后跟着m条路线,箭头为指向,数字为花费。求出从公司派出车,到每个城市回收破车的最小花费,要注意每辆车只能回收一辆破车。用Floyd求出 d[u][v] 的花费。注意有重边!#include<iostream> #include<cstdio> #incl

HJ 396

hdu2923 Einbahnstrasse map+floyd最短路

题意啊,题意很重要!!N 第一个名字是拖车公司,后面的c个是破车的地方,所以有可能出现几个破车在同一个地方的。 而拖车一次只能拖一辆,所以要用一个数组记录下每个破车的位置。 就因为这,RE了我N次! 建图过程也挺麻烦,主要是字符串的处理 #include #include #include #include #include using namespace std; map m

910

HDU 2923 Einbahnstrasse(最短路 Floyd)

题意:给出三个数 n, c, r n 个地点(包括公司的车库),c 表示c辆车抛锚的地点, r 条道路 第二行给出 c+1 个地点,第一个为车库地点, 其余的 c 个为车的地点。 接下来的 r 行表示 r 条有向的道路, s1 -- d -> s2 表示 s1到s2 的长度为 d s1 <- d -- s2 表示 s2到s1 的长度为 d s1 <- d -> s2 表示 s1到s2为双向边, 且长度为 d 拖车从车库出发到每个地点,在该地点拖回抛锚的车子。 一辆拖车一次只能拖

晚风中的自由 786
上一篇: POJ 3461 - Oulipo(KMP)
下一篇: HDU 2647 - Reward(拓扑排序)
coco430
博客等级 码龄14年 9粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值