The building in discuss is about to collapse ....
It was originally written using krusual, but it was always wrong. I had to change the prime.
[Csharp]
# Include "stdio. h"
# Include "string. h"
# Define INF 99999999
Int map [101] [101], mark [101], f [101];
Int n;
Void prime ()
{
Int I, j, k, min, sum;
Memset (mark, 0, sizeof (mark ));
For (I = 1; I <= n; I ++)
F [I] = map [1] [I];
F [1] = 0; mark [1] = 1;
Sum = 0;
For (I = 1; I <n; I ++)
{
Min = INF;
For (j = 1; j <= n; j ++)
{
If (! Mark [j] & f [j] <min)
{
Min = f [j]; k = j;
}
}
Sum + = min;
Mark [k] = 1;
For (j = 1; j <= n; j ++)
{
If (! Mark [j] & map [k] [j] <f [j])
F [j] = map [k] [j];
}
}
Printf ("% d \ n", sum );
}
Int main ()
{
Int I, j, t, x, y;
While (scanf ("% d", & n )! =-1)
{
For (I = 1; I <= n; I ++)
{
For (j = 1; j <= n; j ++)
Scanf ("% d", & map [I] [j]);
}
Scanf ("% d", & t );
For (I = 0; I <t; I ++)
{
Scanf ("% d", & x, & y );
Map [x] [y] = map [y] [x] = 0;
}
Prime ();
}
Return 0;
}
Author: yyf572132811