📄 usaco 3_1_1 agri-net 题解_leokan的blog.mht
字号:
href=3D"http://hi.baidu.com/leokan/profile">=B8=F6=C8=CB=B5=B5=B0=B8</A> =
<SPAN>|</SPAN><A=20
href=3D"http://hi.baidu.com/leokan/friends">=BA=C3=D3=D1</A> =
<SPAN>|</SPAN><A=20
href=3D"http://hi.baidu.com/leokan/modify/spbasic/0">=C9=E8=D6=C3</A> =
</DIV></DIV>
<DIV class=3Dstage>
<DIV class=3Dstagepad>
<DIV style=3D"WIDTH: 100%">
<TABLE class=3Dmodth cellSpacing=3D0 cellPadding=3D0 width=3D"100%" =
border=3D0>
<TBODY>
<TR>
<TD class=3Dmodtl width=3D7> </TD>
<TD class=3Dmodtc noWrap>
<DIV class=3Dmodhead><SPAN =
class=3Dmodtit>=B2=E9=BF=B4=CE=C4=D5=C2</SPAN></DIV></TD>
<TD class=3Dmodtc noWrap align=3Dright>
<DIV class=3Dmodopt><A class=3Dmodact=20
href=3D"http://hi.baidu.com/leokan/creat/blog/"><IMG=20
src=3D"http://img.baidu.com/hi/img/ico_postnew.gif" =
align=3DabsMiddle=20
border=3D0>=D0=B4=D0=C2=CE=C4=D5=C2</A></DIV></TD>
<TD class=3Dmodtr width=3D7> </TD></TR></TBODY></TABLE>
<DIV class=3Dmodbox id=3Dm_blog>
<DIV class=3Dtit>USACO 3.1.1 Agri-Net =CC=E2=BD=E2</DIV>
<DIV class=3Ddate>2008=C4=EA01=D4=C231=C8=D5 =D0=C7=C6=DA=CB=C4 =
15:47</DIV>
<TABLE style=3D"TABLE-LAYOUT: fixed">
<TBODY>
<TR>
<TD>
<DIV class=3Dcnt>
<H2>USACO 3.1.1 Agri-Net</H2>
<DIV class=3Dt_msgfont>Agri-Net<BR>Russ Cox <BR>Farmer John has =
been elected=20
mayor of his town! One of his campaign promises was to bring =
internet=20
connectivity to all farms in the area. He needs your help, of =
course.=20
<BR><BR>Farmer John ordered a high speed connection for his farm =
and is=20
going to share his connectivity with the other farmers. To =
minimize cost,=20
he wants to lay the minimum amount of optical fiber to connect his =
farm to=20
all the other farms. <BR><BR>Given a <SPAN class=3Dt_tag=20
href=3D"tag.php?name=3Dlis">lis</SPAN>t of how much fiber it takes =
to connect=20
each pair of farms, you must find the minimum amount of fiber =
needed to=20
connect them all together. Each farm must connect to some other =
farm such=20
that a packet can flow from any one farm to any other farm. =
<BR><BR>The=20
distance between any two farms will not exceed 100,000. =
<BR><BR>PROGRAM=20
NAME: agrinet<BR>INPUT FORMAT<BR>Line 1: The number of =
farms,=20
N (3 <=3D N <=3D 100). <BR>Line =
2..end: The=20
subsequent lines contain the N x N connectivity matrix, where each =
element=20
shows the distance from on farm to another. Logically, they are N =
lines of=20
N space-separated integers. Physically, they are limited in length =
to 80=20
characters, so some lines continue onto others. Of course, the =
diagonal=20
will be 0, since the distance from farm i to itself is not =
interesting for=20
this problem. <BR><BR>SAMPLE INPUT (file agrinet.in) =
<BR>4<BR>0=20
4 9 21<BR>4 0 8 17<BR>9 8 0 16<BR>21 17 16 0<BR><BR>OUTPUT =
FORMAT<BR>The=20
single output contains the integer length that is the sum of the =
minimum=20
length of fiber required to connect the entire set of farms.=20
<BR><BR>SAMPLE OUTPUT (file=20
=
agrinet.out)<BR>28<BR><BR><BR><BR>Agri-Net<BR><BR>=D7=EE=B6=CC=CD=F8=C2=E7=
<BR><BR>Russ Cox=20
<BR><BR>=D2=EB by=20
=
Leontea<BR><BR>=C5=A9=C3=F1=D4=BC=BA=B2=B1=BB=D1=A1=CE=AA=CB=FB=C3=C7=D5=F2=
=B5=C4=D5=F2=B3=A4=A3=A1=CB=FB=C6=E4=D6=D0=D2=BB=B8=F6=BE=BA=D1=A1=B3=D0=C5=
=B5=BE=CD=CA=C7=D4=DA=D5=F2=C9=CF=BD=A8=C1=A2=C6=F0=BB=A5=C1=AA=CD=F8=A3=AC=
=B2=A2=C1=AC=BD=D3=B5=BD=CB=F9=D3=D0=B5=C4=C5=A9=B3=A1=A1=A3=B5=B1=C8=BB=A3=
=AC=CB=FB=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=C9=CA=F7,prim=CB=E3=B7=A8.</STRONG></P>
<P><STRONG>{<BR>TASK:agrinet<BR>LANG:PASCAL<BR>}<BR>program=20
agrinet;<BR>var<BR> map:array[1..100,1..100] of=20
longint;<BR> n:integer;<BR>procedure=20
init;<BR>var<BR> =20
i,j:integer;<BR>begin<BR> =20
assign(input,'agrinet.in');reset(input);<BR> =20
readln(n);<BR> for i:=3D1 to n=20
do<BR> for j:=3D1 to n=20
=
do<BR> =
read(map[i,j]);<BR> =
close(input);<BR>end;<BR>procedure=20
prim;<BR>var<BR> =
mst,min:longint;<BR> =20
u,t,i,j:integer;<BR> {intree:array[1..100] of=20
boolean;}<BR> dis:array[1..100] of=20
longint;<BR>begin<BR> =
mst:=3D0;<BR> =20
min:=3Dmaxlongint;<BR> =20
{intree[1]:=3Dtrue;}<BR> for i:=3D1 to n=20
do<BR> =20
=
begin<BR> &nbs=
p;=20
=
dis[i]:=3Dmap[1,i];<BR> &n=
bsp; =20
if (dis[i]<min)and (i<>1)=20
=
then<BR>  =
; =20
=
begin<BR> &nbs=
p; =20
=
min:=3Ddis[i];<BR> &=
nbsp; =20
=
u:=3Di;<BR> &n=
bsp; =20
end;<BR> =20
end;<BR> for i:=3D1 to n-1=20
do<BR> =20
=
begin<BR> &nbs=
p;=20
=
{intree[u]:=3Dtrue;}<BR> &=
nbsp; =20
=
inc(mst,dis[u]);<BR>  =
; =20
=
dis[u]:=3D0;<BR> &nb=
sp; =20
=
t:=3Du;<BR> &n=
bsp;=20
=
min:=3Dmaxlongint;<BR> &nb=
sp; =20
for j:=3D1 to n=20
=
do<BR> &=
nbsp; =20
=
begin<BR> &nbs=
p; =20
if dis[j]>map[t,j]=20
=
then<BR>  =
; =
=20
=
dis[j]:=3Dmap[t,j];<BR> &n=
bsp; =20
if (dis[j]<>0)and(dis[j]<min)=20
=
then<BR>  =
; =
=20
=
begin<BR> &nbs=
p;  =
; =20
=
min:=3Ddis[j];<BR> &=
nbsp; &n=
bsp; =20
=
u:=3Dj;<BR> &n=
bsp; &nb=
sp;=20
=
end;<BR>  =
; =20
end;<BR> =20
end;<BR> =20
=
assign(output,'agrinet.out');rewrite(output);<BR> =20
writeln(mst);<BR> =20
close(output);<BR>end;<BR>begin<BR> =20
init;<BR> prim;<BR>end.</STRONG></P>
<P><FONT =
color=3D#ff0000><STRONG>=CE=D2=D2=D4=C7=B0=B5=C4=CC=E2=BD=E2......=C4=C7=CA=
=B1=D5=E6=CA=C7=C8=F5=B0=A1</STRONG></FONT><A=20
=
href=3D"http://hi.baidu.com/leokan/blog/item/30b92c3f5b04f4ef54e723a2.htm=
l"><FONT=20
=
color=3D#ff0000><STRONG>http://hi.baidu.com/leokan/blog/item/30b92c3f5b04=
f4ef54e723a2.html</STRONG></FONT></A></P>
<P><FONT=20
=
color=3D#008080><STRONG>=D5=E2=B5=C0=CC=E2=CA=C7=D2=BB=CC=E2=C7=F3=CE=DE=CF=
=F2=CD=BC=B5=C4=D7=EE=D0=A1=C9=FA=B3=C9=CA=F7=B5=C4=CE=CA=CC=E2=A3=AC=B6=F8=
=C7=D2=CA=C7=D7=EE=BB=F9=B1=BE=B5=C4=A3=AC=C3=BB=D3=D0=B9=D8=C1=AA=C8=CE=BA=
=CE=C6=E4=CB=FC=C1=AC=B4=F8=D6=AA=CA=B6=A1=A3</STRONG></FONT></P>
<P><FONT=20
=
color=3D#008080><STRONG>=D4=DA=B5=DA=D2=BB=CC=EC=A3=AC=CE=D2=BD=E2=B4=CB=CC=
=E2=CA=C7=CD=A8=B9=FD=CE=D2=D6=AE=C7=B0=BC=C7=D2=E4=B9=FD=B5=C4=CA=FD=D1=A7=
=B7=BD=B7=A8=A3=AC=CA=FD=D1=A7=B7=BD=B7=A8=BD=E2=CD=BC=B5=C4=D7=EE=B6=CC=B1=
=DF=CA=B9=CD=BC=C1=AC=CD=A8=B5=C4=B7=BD=B7=A8=CA=C7=A3=BA=D5=D2=B5=BD=C3=BF=
=D2=BB=B8=F6=BB=B7=A3=AC=BB=AE=C8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
=E1=B5=E3=D6=D0=B5=C4=D7=EE=D0=A1=C8=A8=D6=B5=B5=C4=B1=DF=A3=AC=D6=B1=B5=BD=
=CB=F9=D3=D0=BD=E1=B5=E3=B1=BB=D1=A1=D4=F1=CE=AA=D6=B9=A1=A3</STRONG></FO=
NT></P>
<P><FONT=20
=
color=3D#008080><STRONG>PS.=B4=CB=CC=E2=D2=BB=BF=AA=CA=BC=CB=B5=CA=B2=C3=B4=
=CA=E4=C8=EB=C3=BF=D0=D080=B8=F6=D7=D6=B7=FB=A3=AC=B2=BB=B9=BB=BB=BB=D0=D0=
=A3=AC=CA=B9=CE=D2=C8=CF=CE=AA=CA=E4=C8=EB=BA=C3=C2=E9=B7=B3=A3=AC=B1=E0=C1=
=CB=D2=BB=B6=CE=BA=C3=B3=A4=B5=C4=B6=C1=C8=EB=B3=CC=D0=F2=A3=AC=BF=B4=C1=CB=
=CB=FC=B5=C4=CA=E4=C8=EB<BR>.......<BR>10002=20
10001 0 10000 10001 10000 10002 10000 10002 10002 10000 10001=20
10001<BR>10002 10001 10002 10002 10002 10001 10001 10002 10002 =
10002 10001=20
10001<BR>10002 10001 10002 10000 10001 10001 10000 10000 10002 =
10002 10000=20
10000<BR>10000 10000 10000 10000 10001 10000 10000 10001<BR>10001 =
10002=20
10000 0 10000 10000 10002 10000 10000 10000 10001 10002 =
10001<BR>10002=20
10001 10002 10000 10001 10002 10000 10002 10002 10001 10002 =
10001<BR>10000=20
10001 10002 10001 10002 10002 10002 10002 10001 10002 10002 =
10000<BR>10002=20
10002 10000 10000 10001 10001 10002=20
=
10002<BR>......<BR>=B2=C5=D6=AA=B5=C0=B2=BB=BB=E1=D3=D0=D2=BB=B8=F6=CA=FD=
=B7=D6=C1=BD=D0=D0=B3=F6=CF=D6=B5=C4=C7=E9=BF=F6=A3=AC=CB=F9=D2=D4=CA=E4=C8=
=EB=D6=BB=D3=C3read n=B4=CE=D4=DAreadln=20
1=B4=CE=BE=CD=D0=D0=C1=CB=A1=A3</STRONG></FONT></P><STRONG>
<HR>
</STRONG>
<P><STRONG>USACO=B5=C4=B7=D6=CE=F6:</STRONG></P>
<P><STRONG>This problem requires finding the minimum spanning tree =
of the=20
given graph. We use an algorithm that, at each step, looks to add =
to the=20
spanning tree the closest node not already in the tree. =
</STRONG></P>
<P><STRONG>Since the tree sizes are small enough, we don't need =
any=20
complicated data structures: we just consider every node each =
time.=20
</STRONG></P><PRE><STRONG>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define MAXFARM 100
int nfarm;
int dist[MAXFARM][MAXFARM];
int isconn[MAXFARM];
void
main(void)
{
FILE *fin, *fout;
int i, j, nfarm, nnode, mindist, minnode, total;
fin =3D fopen("agrinet.in", "r");
fout =3D fopen("agrinet.out", "w");
assert(fin !=3D NULL && fout !=3D NULL);
fscanf(fin, "%d", &nfarm);
for(i=3D0; i<nfarm; i++)
for(j=3D0; j<nfarm; j++)=20
fscanf(fin, "%d", &dist[i][j]);
total =3D 0;
isconn[0] =3D 1;
nnode =3D 1;
for(isconn[0]=3D1, nnode=3D1; nnode < nfarm; nnode++) {
mindist =3D 0;
for(i=3D0; i<nfarm; i++)
for(j=3D0; j<nfarm; j++) {
if(dist[i][j] && isconn[i] && !isconn[j]) {
if(mindist =3D=3D 0 || dist[i][j] < mindist) {
mindist =3D dist[i][j];
minnode =3D j;
}
}
}
assert(mindist !=3D 0);
=20
isconn[minnode] =3D 1;
total +=3D mindist;
}
fprintf(fout, "%d\n", total);
exit(0);
}
</STRONG></PRE>
<H3>Here is additional analysis from Alex Schwendner:</H3>
<P><STRONG>The solution given is O(N3); however, we can obtain =
O(N2) if we=20
modify it by storing the distance from each node outside of the =
tree to=20
the tree in an array, instead of recalculating it each time. Thus, =
instead=20
of checking the distance from every node in the tree to every node =
outside=20
of the tree each time that we add a node to the tree, we simply =
check the=20
value in the array for each node outside of the tree. =
</STRONG></P><PRE><STRONG>#include <fstream.h>
#include <assert.h>
const int BIG =3D 20000000;
int n;
int dist[1000][1000];
int distToTree[1000];
bool inTree[1000];
main ()
{
ifstream filein ("agrinet.in");
filein >> n;
for (int i =3D 0; i < n; ++i) {
for (int j =3D 0; j < n; ++j) {
filein >> dist[i][j];
}
distToTree[i] =3D BIG;
inTree[i] =3D false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -