usaco 2.4 comehome 2008.7.16
来源:互联网 发布:防伪花纹制作软件 编辑:程序博客网 时间:2024/06/03 17:18
usaco 2.4 comehome 2008.7.16
{
1.路是双向的,不是单项的。
2.起始时读入数据出错,当读入一条路x[l1,l2]时,要从x[l2,l1]和x[l1,l2]中选择一条小的(当然,都要大于零),否则就不能得到最优的解。这点题目中似乎暗示了,我却没注意到}
{
ID:
PROG:comehome
LANG:PASCAL
}
program p_comehome;const fin='comehome.in';fout='comehome.out'; nn=52;var a:array['A'..'Z']of longint; b:array['a'..'z']of longint; x:array[1..nn,1..nn]of longint; ch:string;f1,f2:text;u,op,w:char; la,k,max,code,s,n,pz,i,j,l,l1,l2,maxnn:longint;function deal(t:char):longint;begin if t<'a' then begin if (t>op) and (t<>'Z') then op:=t; if a[t]=0 then begin inc(l);a[t]:=l; inc(la); exit(l) end else exit(a[t]) end else begin if b[t]=0 then begin inc(l);b[t]:=l; exit(l) end else exit(b[t]) end;end;procedure init;begin op:='A';la:=0; fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); for i:=1 to nn do for j:=1 to nn do x[i,j]:=99999999; assign(f1,fin);reset(f1); assign(f2,fout);rewrite(f2); readln(f1,n);l:=0; for i:=1 to n do begin readln(f1,ch); val(copy(ch,5,length(ch)-4),s,code); l1:=deal(ch[1]);l2:=deal(ch[3]); x[l1,l2]:=s; if x[l2,l1]<x[l1,l2] then x[l1,l2]:=x[l2,l1] else x[l2,l1]:=x[l1,l2]; end;end;procedure choose;begin for k:=1 to l do for i:=1 to l do if i<>k then for j:=1 to l do if (j<>k)and(i<>j)then if (x[i,j]>x[i,k]+x[k,j])then x[i,j]:=x[i,k]+x[k,j]; end;{-----------------------main---------------------------}begin max:=maxlongint; init; choose; for w:='A' to 'Y' do if a[w]<>0 then begin if x[a[w],a['Z']]<max then begin max:=x[a[w],a['Z']];u:=w;end; end; writeln(f2,u,' ',max); close(f1); close(f2); end.
0 0
- usaco 2.4 comehome 2008.7.16
- usaco 2.4 comehome
- usaco comehome
- USACO 2.4 Bessie Come Home (comehome)
- Translate:USACO/comehome
- USACO comehome Dijkstra
- usaco 3.1 agrinet 2008.7.16
- usaco 2.4
- USACO2.4.4 Bessie Come Home (comehome)
- USACO2.4.4 Bessie Come Home (comehome)
- USACO 2.4.3 Overfencing
- USACO 2.4 ttwo
- USACO 2.4 cow tour
- usaco 2.4 cowtour
- usaco 2.4 fracdec
- usaco 2.4 maze1
- usaco 2.4 ttwo
- Usaco 2.4Overfencing(BFS)
- MySQL实现函数调用
- fzu 2150 Fire Game
- usaco 3.1 agrinet 2008.7.16
- WC2016——还是认真练码力吧
- linux下的/etc/passwd 和/etc/shadow
- usaco 2.4 comehome 2008.7.16
- DICOM:DICOM开源库多线程分析之“ThreadPoolQueue in fo-dicom”
- 使用nginx搭建流媒体直播平台(该方式不适用与多人聊天)
- usaco 3.1 rect1 2008.7.18
- linux下vi与vim编辑器的区别及使用方法
- 5 分钟上手 ECharts
- Https
- usaco 3.1 contact 2008.7.18
- ORA-01691 错误