亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

hdu 2923 Floyd

2019-11-08 02:51:17
字體:
來源:轉載
供稿:網友

題目:

Einbahnstrasse

Time Limit: 2000/1000 MS (java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3405    Accepted Submission(s): 1074PRoblem DescriptionEinbahnstra  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. InputYour 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 -> BA <-v - BA <-v -> BA 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. 
 OutputFor each test case, print the total distance traveled using the following format:k . VWhere k is test case number (starting at 1,) is a space, and V is the result. Sample Input
4 2 5NewTroy Midvale MetrodaleNewTroy   <-20-> MidvaleMidvale   --50-> BakerlineNewTroy    <-5-- BakerlineMetrodale <-30-> NewTroyMetrodale  --5-> Bakerline0 0 0 Sample Output
1. 80

4個城市 2輛破車 5條路

收破車的公司在NewTroy 兩輛破車分別在Midvale Metrodale

接下來為5條路 有單向也有雙向

求回收所有破車的最小來回代價

思路:用Floyd,注意輸入處理,將字符串映射為數字

代碼:

#include<iostream>#include<cstring>#include<cstdio>#include<cstdlib>#include<ctype.h>    //tower()#include<set>  #include<map>  #include<iomanip>// cout<<setprecision(1)<<fixed<<a;#include<vector>   #include<cmath>	#include<algorithm>#include<bitset>#include<limits.h>#include<stack>#include<queue>using namespace std;const int maxn=10000010;const int inf=0x3f3f3f3f;int n,c,m,a[105][105];char save[1005][11];map<string,int> mat;void Floyd(){    int i,j,k;    for(i = 1;i<=n;i++)        for(j = 1;j<=n;j++)            for(k = 1;k<=n;k++)                if(a[j][i]+a[i][k]<a[j][k])                    a[j][k] = a[j][i]+a[i][k];}int main(){//124MS	1680K    int val,cnt,sum,cas = 1;    char s1[11],s2[11],s3[11];    char from,to;    while(scanf("%d%d%d",&n,&c,&m)==3&&(n+c+m)){        sum = 0;        mat.clear();        memset(a,inf,sizeof(a));        for(int i = 0; i<=c; i++) scanf("%s",save[i]);        cnt = 1;        for(int i = 0; i<m; i++){            scanf("%s %c-%d-%c %s",s1,&from,&val,&to,s3);            if(!mat[s1]) mat[s1] = cnt++;            if(!mat[s3]) mat[s3] = cnt++;            int x = mat[s1],y = mat[s3];            if(from == '<' && val<a[y][x]) a[y][x] = val;//輸入可能有重邊             if(to == '>' && val<a[x][y]) a[x][y] = val;        }        Floyd();        for(int i = 1; i<=c; i++) sum+=a[mat[save[0]]][mat[save[i]]]+a[mat[save[i]]][mat[save[0]]];        printf("%d. %d/n",cas++,sum);    }    return 0;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日韩欧美成人网| 亚洲福利视频久久| 日韩美女av在线免费观看| 在线看国产精品| 中文字幕综合一区| 亚洲一区二区三区乱码aⅴ| 中文字幕亚洲情99在线| 亚洲最大的免费| 日韩成人激情影院| 亚洲人成网7777777国产| 综合久久五月天| 久久国产一区二区三区| 中文字幕精品久久久久| 亚洲精品国产suv| 精品久久久av| 色偷偷亚洲男人天堂| 91精品久久久久久久久久| 欧美午夜宅男影院在线观看| 欧美成人精品xxx| 欧美黑人国产人伦爽爽爽| 国产美女精品免费电影| 狠狠色狠狠色综合日日五| 国产高清视频一区三区| 日韩精品中文字| 另类美女黄大片| 亚洲伊人成综合成人网| 欧美精品激情在线| 欧美一级bbbbb性bbbb喷潮片| 国产精品美女免费视频| 欧美福利小视频| 91精品国产91久久久久久最新| 91夜夜未满十八勿入爽爽影院| 国产精品黄色av| 草民午夜欧美限制a级福利片| 两个人的视频www国产精品| 亚洲欧美日韩综合| 国产乱肥老妇国产一区二| 久久久久久有精品国产| 欧美高清视频在线| 国产精品电影在线观看| 亚洲欧美激情视频| 亚洲国产精品嫩草影院久久| 国产成人久久精品| 热久久视久久精品18亚洲精品| 中文字幕在线看视频国产欧美在线看完整| 亚洲第一区中文99精品| 欧美限制级电影在线观看| 亚洲美女黄色片| 欧美国产日韩免费| 亚洲成av人乱码色午夜| 亚洲第一精品夜夜躁人人躁| 欧美精品在线观看| 久久99热这里只有精品国产| 国产精品青青在线观看爽香蕉| 伊人久久大香线蕉av一区二区| 亚洲品质视频自拍网| 国产精品成av人在线视午夜片| 国产精品久久久久久久久| 亚洲aa中文字幕| 久久精品视频在线观看| 日韩激情av在线免费观看| 久久香蕉国产线看观看av| 国产精品国内视频| 国产乱人伦真实精品视频| 国产精品成人av在线| 国内伊人久久久久久网站视频| 亚洲综合第一页| 亚洲免费av片| 成人国产精品久久久久久亚洲| 日韩在线视频二区| 日韩亚洲国产中文字幕| 国产精品最新在线观看| 亚洲视频在线观看视频| 久久久久国色av免费观看性色| 色午夜这里只有精品| 视频一区视频二区国产精品| 久久99青青精品免费观看| 欧洲精品在线视频| 成人国产亚洲精品a区天堂华泰| 国产一区二区三区在线观看视频| 亚洲欧美另类人妖| 欧洲亚洲女同hd| 国产一区二区三区网站| 亚洲а∨天堂久久精品9966| 5278欧美一区二区三区| 美日韩精品免费视频| 成人激情视频小说免费下载| 国产成+人+综合+亚洲欧美丁香花| 欧美性xxxx极品hd满灌| 久久6精品影院| 国内精品久久久久久影视8| 国产一区二区三区日韩欧美| www.xxxx欧美| 亚洲深夜福利网站| 日韩成人在线视频| 中文字幕精品久久久久| 97av在线视频免费播放| 欧美性猛交xxxx黑人| 2019国产精品自在线拍国产不卡| 欧美午夜视频一区二区| 国产区亚洲区欧美区| 欧美激情a在线| 亚洲国产精品久久91精品| 欧美激情视频免费观看| 伊人久久精品视频| 亚洲欧美在线一区二区| 国产色婷婷国产综合在线理论片a| 91精品久久久久久久久久| 日本韩国在线不卡| 亚洲国产日韩一区| 日韩av毛片网| 亚洲女性裸体视频| 国内精品视频在线| 日韩欧美一区二区三区久久| 91高清视频免费| 亚洲三级免费看| 亚洲国产精品一区二区久| 国产精品入口日韩视频大尺度| 日韩激情第一页| 国产成人av网| 68精品国产免费久久久久久婷婷| y97精品国产97久久久久久| 亚洲最大av网站| 亚洲国产精品久久久久| 亚洲国产精品人人爽夜夜爽| 欧美视频在线免费看| 亚洲视频axxx| 亚洲精品97久久| 国产精品精品视频一区二区三区| 亚洲第一精品自拍| 久久九九有精品国产23| 久久久精品国产网站| 欧美最猛性xxxxx免费| 色视频www在线播放国产成人| 久久手机精品视频| 成人福利视频网| 亚洲欧洲日本专区| 国产精品久久中文| 成人中文字幕在线观看| 久久久久国产精品免费| 国内免费久久久久久久久久久| 5566日本婷婷色中文字幕97| 亚洲va久久久噜噜噜| 日韩视频―中文字幕| 97久久精品国产| 国产精品户外野外| 欧美激情免费视频| 欧美丰满少妇xxxxx做受| 日韩精品极品视频| 国产精品久久二区| 国产精品午夜一区二区欲梦| 一区二区三区在线播放欧美| 中文字幕在线看视频国产欧美在线看完整| 亚洲欧美日韩中文视频| 国产精品综合不卡av| 欧美大片欧美激情性色a∨久久| 欧美另类精品xxxx孕妇| 成人黄色大片在线免费观看| 欧美日韩在线免费观看| 久久久免费高清电视剧观看| 国产成人精品日本亚洲专区61| 欧美精品在线观看| 久久久久久久久久久久av| 国产精品综合网站|